Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Windows Command: RUNAS - with a password

Posted on 2009-03-31
6
Medium Priority
?
2,637 Views
Last Modified: 2012-06-27
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
Comment
Question by:Marius0188
  • 3
  • 2
6 Comments
 
LVL 11

Accepted Solution

by:
bmatumbura earned 600 total points
ID: 24029470
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
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 600 total points
ID: 24029480
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
 
LVL 11

Assisted Solution

by:bmatumbura
bmatumbura earned 600 total points
ID: 24029501
You could also try this utility: http://www.softtreetech.com/24x7/archive/53.htm
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 71

Assisted Solution

by:Qlemo
Qlemo earned 300 total points
ID: 24034121
... or psexec from SysInternals (www.sysinternals.com).
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 600 total points
ID: 24034216
Perhaps a better solution could be provided if we knew what you were doing with the registry?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24038012
Great - a "B" and no author feedback...
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question