Link to home
Create AccountLog in
Avatar of schmir1
schmir1Flag for United States of America

asked on

VBScript to call Batch file with admin rights

How do I write a VBScript to call a batch file with admin rights (UAC) on a Win7 PC?  

FYI: I've got a batch file called Setup_ProgFiles.bat.  This batch file contains the following:
  ATTRIB -R "c:\program files\*.*" /S
This is to clear the read-only attribute so my program stored there can run correctly.
ASKER CERTIFIED SOLUTION
Avatar of MaximumIQ
MaximumIQ
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I've used the elevation powertoys, and they work really well.

http://technet.microsoft.com/en-us/magazine/2008.06.elevation.aspx
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of schmir1

ASKER

I would be part of a setup script so could I use the following a let the user enter his password?
  Set objShell = WScript.CreateObject("WScript.Shell")
  objShell.Run("%comspec% /c runas /user:Administrator \\myserver\folder\mybatchfile.bat"), 0, True

I would try it but I can even get the batch file to clear the read-only even run manually.
Avatar of schmir1

ASKER

I never got it to work but thinks it's more of a MIT problem to fix.