Windows Command: RUNAS - with a password

Dear Experts,

I am calling an executable file from a batch file.
Can I runas the exe file and also specifying the password for the runas user in the runas command?

Please show by example.

Kind regards.
@ runas /user:localhost\administrator regedit

Open in new window

Marius0188Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
bmatumburaConnect With a Mentor Commented:
The RUNAS command does not have a password parameter for security reasons. You may have to consider using a third party solution instead like this: http://www.robotronic.de/runasspcEn.html
0
 
sirbountyConnect With a Mentor Commented:
Disclaimer: You'll be exposing the admin password this way...any user can get it to use it as an admin.

But you can try this using vbscript (no way that I know of using a simple bat file).


Dim objShell : Set objShell = CreateObject("Wscript.Shell")
strPassword = "PASSWORD"
strCommand = "regedit"
 
objShell.Run "Runas /user:Administrator " & strCommand
wscript.sleep 2500 'wait 2.5 seconds
objShell.AppActivate "Runas.exe"
objShell.Sendkeys strPassword
objShell.SendKeys "~"

Open in new window

0
 
bmatumburaConnect With a Mentor Commented:
You could also try this utility: http://www.softtreetech.com/24x7/archive/53.htm
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
... or psexec from SysInternals (www.sysinternals.com).
0
 
sirbountyConnect With a Mentor Commented:
Perhaps a better solution could be provided if we knew what you were doing with the registry?
0
 
sirbountyCommented:
Great - a "B" and no author feedback...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.