Need to run batch file on start-up as Administrator
I have a batch file that runs on start-up that prompts the user for the name of the laptop (each laptop has a unique ID). The WMIC command is called to rename the computer and user account to whatever the name of the laptop happens to be. It then maps a
network drive to read from a text file which looks up which Win7 CD Key it should use, and then runs slmgr.vbs -ipk and -ato.
The current user account is an "Administrator" but when running the WMIC or SLMGR.VBS commands, it fails because it's not the Administrator.
I have tried placing the script into the Logon/Logoff policy but the script didn't even run when doing that. I've tried using Schedule Tasks, but because of the username and computer name changes, that causes errors. I've tried adding the script to HKEY_CU\Software\Microsoft\Windows
NT\CurrentVersion\AppCompatFlags\Layers\ and setting the RUNASADMIN flag but that also didn't work.
How do I force the command prompt window to run as an administrator and then execute the script?
August 17th, 2011 9:21am
Right click on Shortcut>Properties>Shortcut Tab>Advanced>Check 'Run as administrator' worked good enough for me.
Free Windows Admin Tool Kit Click here and download it now
August 17th, 2011 10:20am
This is not working for me in Windows 8. I have a shortcut to an EXE file located in"C:\Users\admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup". If I set the shortcut to run as administrator (screenshot attached) then it does
not run at all on startup. If I uncheckmark "Run as Administrator" then it starts fine (but does not have enough privileges to do what it needs to do). In Windows 7 this was not an issue since the current user was a local administrator and did
not need to elevate its privileges further.
Any ideas how I can work around this problem? Thanks!
Ugh... it won't let me attach a screenshot until my "account is verified", whatever that means.
October 23rd, 2012 9:50am