Solved

How to execute a windows batch as admin

Posted on 2013-05-17
5
357 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
[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
5 Comments
 
LVL 28

Expert Comment

by:omgang
ID: 39175247
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
ID: 39175285
Yes you are correct, what I need is runas.
can runas be used with aoutostart?
0
 
LVL 28

Expert Comment

by:omgang
ID: 39175295
autostart?  Not sure I understand.
OM Gang
0
 

Author Comment

by:atorex
ID: 39175365
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
ID: 39175383
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
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…

738 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