Solved

How to execute a windows batch as admin

Posted on 2013-05-17
5
358 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 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