VBScript to start exe with local admin rights

polaris101
polaris101 used Ask the Experts™
on
Hi All - scripting newbie here...  I'm just looking for a simple script to start the install of an exe with admin rights.  Basically, I have about 20 users that need this program installed I'd like to direct them to run the VBS or I'll use group policy to start the script at logon.  These users do not have admin rights to their computers...  I'd like to include the user/pass right inside the VBS if possible.  (I realize this isn't a perfect idea bc of security...but in my case it's fine)

THanks for your help!
Scott
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23020313.html
http://www.joeware.net/freetools/tools/cpau/index.htm

It's not quite as cut and dry as one would hope, but you should be able to accomplish this with a little testing.

To prevent the annoying pop-up, you would have to either add a "Trusted Network Location" for the EXE and script, or copy the files locally to the computer first, then run them from the local machine, deleting when finished.
'slightly modified from the other question's answer
'
Set objShell = CreateObject("Wscript.Shell")
strCommand = "\\server\folder\path\cpau.exe -u username -p password -ex ""\\ServerName\FolderName\filename.msi"" -wait -profile"
objshell.run(strCommand),1, True

Open in new window

Author

Commented:
Thanks for the reply tmassa99, however, I would rather not install that freeware on all the machines if I don't have to.
ThinkPaperIT Consultant

Commented:
What are you trying to install?

With psexec installed on your box (on your box only), you can use it to remotely install the application to the user's systems. Mind you, this depends on the exe having some kind of silent switches so that it can run automatically (silently).

It might not be what you want since you'd have to download it, but it is a Microsoft tool that you'd need to only install once on the 1 box you are pushing the install from. (you do not need to install it on the other workstations)
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

the command would look something like this:

psexec @computerlist.txt -u domain/admin -p password -c "\\server\software\blah.exe" /S

(instead of /S it could be any of these common switches: /quiet /qn /q /silent /s -s
you would need to find out what switches the exe supports - if any)

where computerlist.txt looks like:

computer1
computer2
computer3

Again, this is all dependent on whether the installation supports silent installation. If it doesn't, it requires a bit more work.

The other option is to use Group Policy and attach the software for install. However, this is sometimes a hit or miss...

The problem with doing an install under admin in vbscript is that you'd be pushing code that'd have your admin credentials in it, which can easily be read. It's more difficult to do it this way since you can't use the "runas" command to pipe the password directly. Things are created by default to not allow security problems...
It's a stand-alone utility, which why I said you can run it from the network location or from the network share.  EXE's aren't allowed to execute without warning to the end user.

JoeWare's utilities are almost invariably rock-solid, and certainly don't have any issues.

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/XP/Q_22698604.html#a19495563

There is a script on the "Assisted Solution" that may work.  I've copied the script here
Option explicit
Dim oShell

set oShell= Wscript.CreateObject("WScript.Shell")

'Replace the path with the program you wish to run c:\program files...
oShell.Run "runas /noprofile /netonly /user:domain\user ""C:\Program Files\MICIS\example.exe"""

WScript.Sleep 100

'Replace the string --> yourpassword~ with the
'password used on your system. Include the tilde "~"

oShell.Sendkeys "password~"

Wscript.Quit

Open in new window

Author

Commented:
Thank You for the clarification tmassa99.  Worked perfectly.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial