Run Bat file in Administrator Mode in Windows Server 2008

batch-filevbscriptwindows-command-promptwindows-server-2008

runas.exe /profile /user:administrator "C:\temp\SQLSP3.bat"

will run the SQLSP3.bat file in Administrative Prompt and it is asking Adminstrator password in Windows Server 2008.

SQLSP3.bat file has following code

C:\Temp\SQLSP3.exe /qs /IAcceptSQLServerLicenseTerms /Action=Patch /AllInstances 

Is there any option which i can code the Administrator Password in any of the Script file ?

I don't want UAC to ask me the password. Everything needs to happen silently.
Please help me.

Best Answer

The problem with coding an administrator password into the script file is that you're exposing said password directly to the user. If you don't mind doing that, you're actually better off just giving admin rights to the user (even if it's temporary).

For this upgrade, I gather the rights you need are: Backup files and directories (SeBackupPrivilege) Debug Programs (SeDebugPrivilege) Manage auditing and security log (SeSecurityPrivilege)

If you can, use something like psexec - https://technet.microsoft.com/en-us/sysinternals/psexec.aspx to execute the upgrade remotely. Then you can deploy it from a remote system, where you can enter admin credentials and point the upgrade to the target system.

That's about as lightweight as you can get, so far as I know. Past that, you'll need to investigate remote deployment options. https://serverfault.com/questions/tagged/deployment