thimon Posted July 21, 2016 Posted July 21, 2016 So I'm trying to get a .exe cmd command to run as the local admin user on numerous computers. I've looked into the RunAs command but can't see how you set the computer name to vary per computer. Help!
Rob_D Posted July 21, 2016 Posted July 21, 2016 Using the %computername% variable should work runas /user:%computername%\administrator mycommand.exe Although after some testing not defining any domain seems to make it default to the local machine, so this worked for me as well. runas /user:administrator mycommand.exe 1
sted Posted July 21, 2016 Posted July 21, 2016 Using the %computername% variable should work runas /user:%computername%\administrator mycommand.exe Although after some testing not defining any domain seems to make it default to the local machine, so this worked for me as well. runas /user:administrator mycommand.exe i suspect .\administrator would also work (typing in .\ is a quick way of finding a pc name from the logon screen without actually logging in) 1
thimon Posted July 21, 2016 Author Posted July 21, 2016 Using the %computername% variable should work runas /user:%computername%\administrator mycommand.exe Cheers Rob, this works, however cmd then asks for the administrator password. Is there anyway I can put that into the command? Ideally I'm looking for this to run automatically / silently. Thanks.
Rob_D Posted July 21, 2016 Posted July 21, 2016 i suspect .\administrator would also work (typing in .\ is a quick way of finding a pc name from the logon screen without actually logging in) .\ didn't work for me under the runas, although I may have been doing something wrong.
Rob_D Posted July 21, 2016 Posted July 21, 2016 When and why are you trying to run this? Can it be part of a startup script? You can't save a password into runas, you'd need something like psexec to do this. https://community.spiceworks.com/topic/368007-runas-batch-including-password
3s-gtech Posted July 21, 2016 Posted July 21, 2016 We do it with psexec to run our nasty laser cutter software as local admin for a restricted user. Works fine.
thimon Posted July 21, 2016 Author Posted July 21, 2016 When and why are you trying to run this? Can it be part of a startup script? I'm looking at alternatives to getting Office 2016 installed. Trying to run the .exe silently as the local admin. Our currently process uses PDQ Deploy but takes 15 mins!
Rob_D Posted July 21, 2016 Posted July 21, 2016 I'm looking at alternatives to getting Office 2016 installed. Trying to run the .exe silently as the local admin. Our currently process uses PDQ Deploy but takes 15 mins! How were you planning to trigger the install? If you want a more controllable solution then I'd go for PSExec scripts. This has the advantage of you being able to remotely deploy the installer to multiple machines at once. If you just want to get it out there hands free the I'd put the silent install command in the shutdown script (odds are the computer taking a while to shut down isn't going to inconvenience people) and give it a couple of days. Take the command back out once all the computers are installed. If you wanted to be really clever then you could (I'm assuming, I don't know how PDQ works) use PDQ to drop the install files and a scheduled task onto each machine, the scheduled task would then be set to run with admin credentials at a predefined time that's convenient for everyone. And hopefully running the install from files already on the drive will help bring down the install time.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now