Link to home
Create AccountLog in
Avatar of atorex
atorex

asked on

How to execute a windows batch as admin

Hi, I need to execute an application that opens CMD.exe as a basic user, what I need is to execute the command as an administrator.
is there a way I can create a batch file to execute the app as admin?
Avatar of omgang
omgang
Flag of United States of America image

Runas command may be what you're looking for.

From a command line type
runas /?
for details

in your batch file you could have
Rem run as admin
runas /user:localmachine\administrator "c:\path\MyApp.exe"

You'll receive a prompt for the administrator password.
There's no way (that I know of) to embed the password in the batch file.  This can be done via script, however.
OM Gang
Avatar of atorex
atorex

ASKER

Yes you are correct, what I need is runas.
can runas be used with aoutostart?
autostart?  Not sure I understand.
OM Gang
Avatar of atorex

ASKER

dim wshshell
set wshshell = wscript.createobject("wscript.shell")
wshshell.run "c:\apps\POSTouch.exe", 0, TRUE



I have something like the above, can I pass user and password with the above?
ASKER CERTIFIED SOLUTION
Avatar of omgang
omgang
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account