Runas command syntax for batch file

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?
LVL 4
rstorm1Asked:
Who is Participating?
 
Christopher McKayConnect With a Mentor Microsoft Network AdministratorCommented:
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
 
SappbrostsCommented:
cant you just take out "domainname"?

runas /user:username programname
0
 
SappbrostsCommented:
otherwise trying using the computer name in place of domain name
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Kieran_BurnsCommented:
something like this:
C:\WINDOWS\system32\runas.exe /noprofile /savecred /user:computername\user "C:\WINDOWS\system32\gpmc.msc"
0
 
Kieran_BurnsCommented:
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
 
rstorm1Author Commented:
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
 
leblancchCommented:
Do you not need to use your password in plaintext for this?

CPAU could be another option. You can encrypt that.
0
 
rstorm1Author Commented:
That did the trick, thanks for the help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.