Solved

Windows Command: RUNAS - with a password

Posted on 2009-03-31
6
2,622 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 11

Accepted Solution

by:
bmatumbura earned 200 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 200 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 200 total points
ID: 24029501
You could also try this utility: http://www.softtreetech.com/24x7/archive/53.htm
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 70

Assisted Solution

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

Assisted Solution

by:sirbounty
sirbounty earned 200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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