batch-fileadministratorrunas

Batch Script to Run as Administrator


I'm writing a client/server checking program but it needs to run as Administrator.

I want this to run silently on my network and users, and I don't want the "Run as" Administrator" prompt. Is there any beginning code that I can place into the batch file to make it auto-run as Administrator?


Solution

  • Solutions that did not work

    No: The - create a shortcut [ -> Compatibility -> "run this program as an administrator" ] solution does not work.

    This option is greyed out in Windows 7. Even with UAC disabled

    No: The runas /env /user:domain\Administrator <program.exe/command you want to execute> is also not sufficient because it will prompt the user for the admin password.

    Solution that worked

    Yes: Disable UAC -> Create a job using task scheduler, this worked for me.

    You can let the script enable UAC afterwards by editing the registry if you would want. In my case this script is ran only once by creation of a windows virtual machine, where UAC is disabled in the image.

    Still looking forward for the best approach for a script run as admin without too much hassle.