Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VB script to run a batch script as admin

$
0
0

I have batch script the I need to run as an administrator, I created a VBscript wrapper that calls a runas and runs my batch file, however the batch file is not being elevated high enough on Windows 7 and Vista, it works fine on XP.  The batch script needs to create a folder in Program files, and copy the necessary files, install several programs, as well as make several registry key changes.  If I am logged in as a user with admin rights, right click on the batch file and select "Run as Administrator" the batch works fine.  Using the VBscript to elevate the rights, it installs the programs, but when it comes to creating the folder in Program files\Program data and Registry edits, it fails.  Is there any way to script so I can elevate the batch file to the same level as selecting "Run as Administrator?

 

 

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("runas /user:domain\user \\unc\location\Install.bat"), 1, True
WScript.Sleep 100
oShell.Sendkeys "password~"

 

Another issue, I am having with the script is that it will not send the password, I have to type it manually to test.

 

The idea is to have the end user be able to click on a link from a webpage and install the program itself, as opposed for our Helpdesk be required to install the program.  So psexec is no doable as it is not on any of the PCs and user login scripts is not an option either, as we don't want the program install on every PC.

 




Viewing all articles
Browse latest Browse all 15028

Trending Articles