Solved

How to execute a windows batch as admin

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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 …
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 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

14 Experts available now in Live!

Get 1:1 Help Now