Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2643
  • Last Modified:

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

0
Marius0188
Asked:
Marius0188
  • 3
  • 2
5 Solutions
 
bmatumburaCommented:
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
 
sirbountyCommented:
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
 
bmatumburaCommented:
You could also try this utility: http://www.softtreetech.com/24x7/archive/53.htm
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
QlemoC++ DeveloperCommented:
... or psexec from SysInternals (www.sysinternals.com).
0
 
sirbountyCommented:
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now