Jump to content

Error with sleep command after importing a .reg to run a Windows update from WSUS


st4vr0s
 Share

Recommended Posts

Hi,

I have a very very basic script which reads,

Run ("Regedit.exe /s import C:\WSUSUpdateII\ConfigureWSUS.reg")

Sleep 5000

Run ("C:\WSUSUpdateII\RunWSUS.bat")

which basically imports ....

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate]

"WUServer"="http://server"

"WUStatusServer"="http://server"

"ElevateNonAdmins"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU]

"UseWUServer"=dword:00000001

"AutoInstallMinorUpdates"=dword:00000001

"DetectionFrequencyEnabled"=dword:00000001

"DetectionFrequency"=dword:00000001

"NoAutoUpdate"=dword:00000000

"AUOptions"=dword:00000003

"ScheduledInstallDay"=dword:00000000

"ScheduledInstallTime"=dword:00000009

"RescheduleWaitTimeEnabled"=dword:00000001

"RescheduleWaitTime"=dword:00000001

Into the registry, then runs the bat file....

@echo off

Set KEY="HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"

REG ADD %KEY% /V "WUServer" /t REG_SZ /d "http://server:80" /f

REG ADD %KEY% /V "WUStatusServer" /t REG_SZ /d "http://server:80" /f

REG ADD %KEY% /V "ElevateNonAdmins" /t REG_DWORD /d "1" /f

SET KEY="HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"

REG ADD %KEY% /V "UseWUServer" /t REG_DWORD /d "1" /f

REG ADD %KEY% /V "AutoInstallMinorUpdates" /t REG_DWORD /d "1" /f

REG ADD %KEY% /V "DetectionFrequencyEnabled" /t REG_DWORD /d "1" /f

REG ADD %KEY% /V "DetectionFrequency" /t REG_DWORD /d "1" /f

REG ADD %KEY% /V "NoAutoUpdate" /t REG_DWORD /d "0" /f

REG ADD %KEY% /V "AUOptions" /t REG_DWORD /d "3" /f

REG ADD %KEY% /V "ScheduledInstallDay" /t REG_DWORD /d "0" /f

REG ADD %KEY% /V "ScheduledInstallTime" /t REG_DWORD /d "9" /f

REG ADD %KEY% /V "RescheduleWaitTimeEnabled" /t REG_DWORD /d "1" /f

REG ADD %KEY% /V "RescheduleWaitTime" /t REG_DWORD /d "1" /f

Net Stop wuauserv

net start wuauserv

wuauclt /detectnow /resetauthorisation /downloadnowfast

copy "\\server\distribution$\applications\WSUSUpdateII\removeWSUS.reg" "%ALLUSERSPROFILE%\desktop"

dir c:\ /s >nul

dir c:\ /s >nul

netstat -an |find "192.168.1.200:80"

If I keep the sleep in I get an error message but when removed it seems to work.

The reason for the sleep is to make sure the import is complete before it runs the .bat file.

Any suggestions on the best way to achieve this?

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...