Solved

How to execute a windows batch as admin

Posted on 2013-05-17
5
351 Views
Last Modified: 2013-05-23
Hi, I need to execute an application that opens CMD.exe as a basic user, what I need is to execute the command as an administrator.
is there a way I can create a batch file to execute the app as admin?
0
Comment
Question by:atorex
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:omgang
Comment Utility
Runas command may be what you're looking for.

From a command line type
runas /?
for details

in your batch file you could have
Rem run as admin
runas /user:localmachine\administrator "c:\path\MyApp.exe"

You'll receive a prompt for the administrator password.
There's no way (that I know of) to embed the password in the batch file.  This can be done via script, however.
OM Gang
0
 

Author Comment

by:atorex
Comment Utility
Yes you are correct, what I need is runas.
can runas be used with aoutostart?
0
 
LVL 28

Expert Comment

by:omgang
Comment Utility
autostart?  Not sure I understand.
OM Gang
0
 

Author Comment

by:atorex
Comment Utility
dim wshshell
set wshshell = wscript.createobject("wscript.shell")
wshshell.run "c:\apps\POSTouch.exe", 0, TRUE



I have something like the above, can I pass user and password with the above?
0
 
LVL 28

Accepted Solution

by:
omgang earned 500 total points
Comment Utility
wshshell.run runas /user:administrator "c:\apps\POSTouch.exe, 0, TRUE"

You may need to experiment with how to pass the arguments
OM Gang
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now