Saturday, September 13, 2014

uac - Run this bat file with admin rights


I have written a simple bat file to run a silverlight install at login.


I have the script called via GPO and AD, but when it runs, i have the issue of admin rights and UAC.


Is there a way to stream the admin username and password into the script so it will install??



`setlocal


set
DeployServer=\10.0.30.7\installs\Silverlight\


set InstallerName=Silverlight.exe /q


Set
LogLocation=\10.0.30.7\installs\SilverlightLogs


REM
************************************************************************* REM Deployment code begins here. Do
not modify anything below this line.
REM




reg query
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Silverlight
if %errorlevel%==1 (goto
DeploySilverlight) else (goto End)


REM If 1 returned, the product was not
found. Run setup here.
:DeploySilverlight start /wait
%DeployServer%\%InstallerName% echo
%date% %time% Setup ended with error
code %errorlevel%. >>
%LogLocation%\%computername%.txt


REM If 0 or other was returned, the
product was found or another error
occurred. Do nothing. :End


Endlocal



This is what i have so far.


Answer



Native runas cannot be passed a password, you'd have to use a 3rd party app. The following is free, the full version allows you to encrypt the password:


http://www.softtreetech.com/24x7/archive/53.htm


Then you could call the batchfile from within another batchfile containing the following:


runas user@domain.com password yourbatchfile.bat


That's about the best solution I can come up with for you ...


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...