SU or RUNAS from a batch file

D

David

Hi,

Can anybody help me out with a way to run either SU or
RUNAS from within a batch file or VBS so that it does not
prompt for a password?

Thanks in advance

David
 
M

Mike Deering

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "runas.exe /env /user:DOMAINNAME\USERNAME
O:\pc_bin\installs\ASM\m730silent.exe"

WshShell.Sendkeys "PASSWORD FOR ABOVE"
WshShell.Sendkeys "~"
 
M

myself

just don't use /savecred as that would allow end users to run any
application as Admin, as after all, you save the admin password for them.
 
M

Matt Hickman

David said:
Hi,

Can anybody help me out with a way to run either SU or
RUNAS from within a batch file or VBS so that it does not
prompt for a password?

for a batch file:
1. create a file with its only contents being the password and a CR/LF

2. runas /user:SU cmd.exe < pswd.txt
 
A

Al Dunbar [MS-MVP]

Matt Hickman said:
"David" <[email protected]> wrote in message

for a batch file:
1. create a file with its only contents being the password and a CR/LF

2. runas /user:SU cmd.exe < pswd.txt

I didn't think that the password was redirectible like that. My only problem
now is that I get error "1326: logon failure: unknown username or bad
password". Same command without the redirection worked, so I know I typed
the username correctly. Double-checked the password and tried with and
without crlf. Even used debug to verify it was crlf and not just lf.


/Al
 
M

Matt Hickman

Al Dunbar said:
I didn't think that the password was redirectible like that. My only problem
now is that I get error "1326: logon failure: unknown username or bad
password". Same command without the redirection worked, so I know I typed
the username correctly. Double-checked the password and tried with and
without crlf. Even used debug to verify it was crlf and not just lf.
My fault, I forgot runas will not accept redirection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top