At a customer I had the problem that we had there a logon scrip, but we were given no access to the registry. Well, we had local administrave permissions. At first I tried runas, but we have to save the password – no chance. Not even echo password works. lsrunase seems to solve the problem, but the version that I found, had problems with quotes in quotation marks. At the end I used a simple AutoIt script.
AutoIt Script (runas.exe)
|
Local $sUserName = "Administrator" Local $sPassword = "password" ;Run a command prompt as the other user. if $CmdLine[0] > 0 Then RunAs($sUserName, @ComputerName, $sPassword, 0, $CmdLine[1]) endif |
Change reg entry for HKLM
|
\\server\scripte$\runas.exe "reg add ""HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\BootAnimation"" /f /v ""DisableStartupSound"" /t REG_DWORD /d ""0"" " |
Change reg entry for current user (HKCU don’t work because you run as local admin!)
|
for /f "delims= " %%a in ('"wmic path win32_useraccount where name='%UserName%' get sid"') do ( if not "%%a"=="SID" ( set SID=%%a goto :loop_end ) ) :loop_end echo %sid% \\server\scripte$\runas.exe "reg add ""HKU\%SID%\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects"" /f /v ""VisualFXSetting"" /t REG_SZ /d ""3"" " |
Reg changes and file copy (also used quotes in quotation marks and concatenate cmd commands)
|
\\server\scripte$\runas.exe "reg add ""HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background"" /f /v ""OEMBackground"" /t REG_DWORD /d ""1"" " \\server\scripte$\runas.exe "cmd /c mkdir C:\Windows\System32\oobe\info\backgrounds&net use \\server\scripte$ /user:contoso.local\admin password&echo d|xcopy ""\\server\scripte$\Wallpaper\backgroundDefault.jpg"" ""C:\Windows\System32\oobe\info\backgrounds\backgroundDefault.jpg"" /Y /R /E /S /C" |