?
Solved

Runas command syntax for batch file

Posted on 2009-04-29
8
Medium Priority
?
1,128 Views
Last Modified: 2012-05-06
Trying to get a batch file to run as local administrator.  This file will be used on different computers randomly, so I want to be able to have it run under the computer local administrator account.  Can someone tell me how to denote this in the runas command line?
This shows how to do this as a domain admin:

runas /user:domainname\username programname

What can I put in place of "domainname" to generically denote the local computer?
0
Comment
Question by:rstorm1
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 7

Expert Comment

by:Sappbrosts
ID: 24261837
cant you just take out "domainname"?

runas /user:username programname
0
 
LVL 7

Expert Comment

by:Sappbrosts
ID: 24261840
otherwise trying using the computer name in place of domain name
0
 
LVL 22

Accepted Solution

by:
Christopher McKay earned 2000 total points
ID: 24261853
You could try using the %computername% environment variable. That way it checks for the computer name of whichever computer it's run on.

Hope this helps!

:o)

Bartender_1
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 10

Expert Comment

by:Kieran_Burns
ID: 24261854
something like this:
C:\WINDOWS\system32\runas.exe /noprofile /savecred /user:computername\user "C:\WINDOWS\system32\gpmc.msc"
0
 
LVL 10

Expert Comment

by:Kieran_Burns
ID: 24261869
Ah yes - sorry missed the 'generic' bit - in which case change computername\user to .\user
This will pick the LOCAL computer as the device
0
 
LVL 4

Author Comment

by:rstorm1
ID: 24270957
Having to stomp some other fires at the moment, will get back to testing this as soon as I can.  Thanks for the help so far!
0
 

Expert Comment

by:leblancch
ID: 24318505
Do you not need to use your password in plaintext for this?

CPAU could be another option. You can encrypt that.
0
 
LVL 4

Author Closing Comment

by:rstorm1
ID: 31576001
That did the trick, thanks for the help!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

864 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