joefitzgerald / packer-windows

Windows Packer Templates
MIT License
1.63k stars 1.12k forks source link

Avoid Windows login when auto-updating with win-updates.ps1 #219

Open Conlapped opened 7 years ago

Conlapped commented 7 years ago

Hi,

I want to use win-updates.ps1 in order to spend less time updating and restarting clients. It seems to work fine but Windows always asks for the adimin password when restarting. Is there a way to bypass it as long as the script is running? I'd like the client to update + restart as long as their are updates available and restore the admin-passwort afterwards. I know that there is a registry key called "AutoAdminLogon" but I am not sure how and where to include it.

I apreciate any help =)

glangfield commented 7 years ago

You can get creative and create a windows service that calls an .exe (I've used PrimalScript to wrap a .ps1) and make an .exe from it.

You can use instsrv.exe and srvany.exe to create and manage the service. You will also need to create a registry key for this. Something similar to below.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NAME OF SERVICE] "Start"=dword:00000004 "DependOnService"="wuauserv"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NAME OF SERVICE\Parameters] "Application"="c:\script.exe"