Right click > RunAs into a .cmd file

tgabe213

2[H]4U
Joined
Aug 27, 2007
Messages
3,684
I'm setting up a few applications to install silently when a user logs on. The login script calls a .vbs file, which in turn calls my .cmd file. I have it calling the vbs file because this allows me to run it hidden, and not minimized.

What I'm finding with users that don't have the rights to install applications, they are getting the RunAs prompt when the application trys to install. How can I automate the runas command in my .cmd file?

applicationInstalls.vbs
Code:
Set oShell = CreateObject("WSCript.shell") 
sCmd = "\\domain\NETLOGON\applicationInstalls.cmd"
oShell.Run sCmd, 0, False ' The 0 will make it run hidden

applicationInstalls.cmd
Code:
@echo off

:Adobe_Reader9.3
"G:\INSTALL\Adobe\Adobe9.3\AdbeRdr930_en_US.exe /sAll /rs /l /msi"/qb-! /norestart ALLUSERS=1 EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES""

:End

Everything works good when it's an administrator logging on. Any ideas?
 
Sounds like PsTools might be right for the job.
PsTools: http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx
PsExec specifically: http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

I've never used it to install apps on login, always done that w/ group policy if needed.
http://support.microsoft.com/kb/816102

If you still want to use runas check this out:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/runas.mspx?mfr=true

PS: good idea not having users as local admins :p the frustrations are well worth it when you don't have to do anymore virus cleanup
 
Sounds like PsTools might be right for the job.
PsTools: http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx
PsExec specifically: http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

I've never used it to install apps on login, always done that w/ group policy if needed.
http://support.microsoft.com/kb/816102

If you still want to use runas check this out:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/runas.mspx?mfr=true

PS: good idea not having users as local admins :p the frustrations are well worth it when you don't have to do anymore virus cleanup

Thanks for the runas link. Looks like that option is out because it still prompts the user for the password.

PsExec looks great and that it should work. Do you know of a way to run multiple computers at once? I'm trying to automate the installation across ~500 computers.
 
Actually, it basically just becomes a new command on the command prompt, so I think I could alter my applicationInstall.cmd file to run a psExec command. It would have to be run locally though. I wonder what an easy way would be to target all of the remote PC's. I could setup a scheduled task on my computer to run the command, but how to target all PC's?

Hmm..
 
I could just push out the PsExec.exe to every PC, then still run with the same setup, right? Hmmm again.
 
No.. It's ran from like your desktop or a server or whatever.

psexec -c -f \\pcname AdbeRdr930_en_US.exe" /sAll /rs /l /msi"/qb-! /norestart ALLUSERS=1 EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES"

Thats what I'm using.
 
No.. It's ran from like your desktop or a server or whatever.

psexec -c -f \\pcname AdbeRdr930_en_US.exe" /sAll /rs /l /msi"/qb-! /norestart ALLUSERS=1 EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES"

Thats what I'm using.

What? I'm not sure what you're trying to say.

So when I specify the file to be run, that's a local file, correct?
 
What? I'm not sure what you're trying to say.

So when I specify the file to be run, that's a local file, correct?

psexec is run from your local machine, and you push out the file to all remote machines, from the local machine.

psexec uses the local credentials on the remote machine for installation.

might be easier to repackage the exe as an MSI file and use GPO though, no?

edit: this may be helpful
Extract the Adobe Reader 9.x installation files
Extract the Adobe Reader 9.x installation files from the compressed executable:

1.Obtain Adobe Reader 9.x by filling out an Adobe Reader Redistribution Agreement at www.adobe.com/products/acrobat/distribute.html.
2.Download the AdbeRdr9x_en_US.exe from the link in the confirmation email you recieve after filling out the distribution agreement and save the file to your desktop.
3.Choose Start > Run.
4.In the Open text box, type: "%UserProfile%\Desktop\AdbeRdr9x_en_US.exe" -nos_ne.
5.Click OK to start decompressing the file.
6.When the Adobe Reader 9.x Setup screen clears, browse to the following location
%UserProfile%\Local Settings\Application Data\Adobe\Reader 9.0\Setup Files
7.Drag the READER9 folder to your desktop. This folder contains AcroRead.msi and Data1.cab files needed for installation.

http://kb2.adobe.com/cps/404/kb404146.html
 
Last edited:
psexec is run from your local machine, and you push out the file to all remote machines, from the local machine.

psexec uses the local credentials on the remote machine for installation.

might be easier to repackage the exe as an MSI file and use GPO though, no?

That would be the best method. Anything you script is going to need the password at some point to elevate privilege, either in a request like you have now or stored in the script (bad idea).
 
psexec is run from your local machine, and you push out the file to all remote machines, from the local machine.

psexec uses the local credentials on the remote machine for installation.

might be easier to repackage the exe as an MSI file and use GPO though, no?

I get it now, thanks.

This is how it's been installed on the majority of our PC's, but, unfortunately, we're running Novell servers at all locations, with 2 windows DC's. The cabinet file for adobe is 100MB, and each PC needs to copy the .cab and .msi to the local machine, then install. This process takes about 25-35 minutes. It really screws things up if someone needs to reboot in the middle of the day and they don't have it yet. It would be easy to put the MSI on the servers at each location, but they have no authentication for the Novell server at the time of GP. Ideas perhaps?
 
see my edit above for extracting the MSI file for installation via GPO's.
save some time :)

ninja edit: err, ok just read that last reply. I am unfamiliar with Novell, so no help there.
 
Back
Top