Entering local admin username and password in a script

Solution 1:

Start your batch:

powershell.exe -Command "Start-Process cmd -Verb RunAs"
...
rest of script
...

This will open an elevated command prompt

Keep in mind for this to work the user would need to have admin privilege on the box.

If the user is not a local admin you will have the use the /savecred switch, this is a big security hole as then the user and can use the /savecred switch on anything else they want.

If you have AD you can always do this through GPO.