tedpenner
asked on
scripting batch file commands
I need batch file commands for the following.
Turn off Windows system restore
Turn off Windows automatic updates (and I suppose some way to make the little redx warning in the task bar go away once it's disabled)
Reboot Computer
Turn off Windows system restore
Turn off Windows automatic updates (and I suppose some way to make the little redx warning in the task bar go away once it's disabled)
Reboot Computer
From http://www.jsifaq.com/subr/tip8900/rh8979.htm: This is for a batch file named DisableRP.bat.
The syntax for using DisableRP.bat is:
DisableRP Drive RetVal
Where Drive is the drive letter of the drive on which you want to disable System Restore, or ALL to disable it on all drives, and RetVal is a call directed environment variable that will contain a Y if the script was successful, or a N is the script failed to disable the requested object.
NOTE: If you disable System Restore on the boot drive, System Restore will be disabled on all drives.
NOTE: The boot drive is the drive that contains the Windows folder, and the system drive is the drive that contains the files that Windows uses to start, like Boot.ini, NTLDR, etc..
DisableRP.bat contains:
@echo off
if {%2}=={} @echo Syntax: DisableRP Drive RetVal&goto :EOF
setlocal
set work=%1
if /i "%work%" NEQ "ALL" set drive=%work:~0,1%:\
set DisableRPVBS="%TEMP%\Disab leRP_%RAND OM%.VBS"
set OK=N
@echo Set objArgument = Wscript.Arguments>%Disable RPVBS%
@echo If objArgument.Count() ^> 0 Then>>%DisableRPVBS%
@echo Drive = objArgument(0)>>%DisableRP VBS%
@echo Else>>%DisableRPVBS%
@echo Drive = "">>%DisableRPVBS%
@echo End If>>%DisableRPVBS%
@echo Set obj = GetObject("winmgmts:{imper sonationLe vel=impers onate}!roo t/default: SystemRest ore")>>%Di sableRPVBS %
@echo If (obj.Disable(Drive)) = 0 Then>>%DisableRPVBS%
@echo wscript.Echo "Y">>%DisableRPVBS%
@echo Else>>%DisableRPVBS%
@echo wscript.Echo "N">>%DisableRPVBS%
@echo End If>>%DisableRPVBS%
for /f "Tokens=*" %%d in ('cscript //nologo %DisableRPVBS% %drive%') do (
set OK=%%d
)
del /q %DisableRPVBS%
endlocal&set %2=%OK%
The syntax for using DisableRP.bat is:
DisableRP Drive RetVal
Where Drive is the drive letter of the drive on which you want to disable System Restore, or ALL to disable it on all drives, and RetVal is a call directed environment variable that will contain a Y if the script was successful, or a N is the script failed to disable the requested object.
NOTE: If you disable System Restore on the boot drive, System Restore will be disabled on all drives.
NOTE: The boot drive is the drive that contains the Windows folder, and the system drive is the drive that contains the files that Windows uses to start, like Boot.ini, NTLDR, etc..
DisableRP.bat contains:
@echo off
if {%2}=={} @echo Syntax: DisableRP Drive RetVal&goto :EOF
setlocal
set work=%1
if /i "%work%" NEQ "ALL" set drive=%work:~0,1%:\
set DisableRPVBS="%TEMP%\Disab
set OK=N
@echo Set objArgument = Wscript.Arguments>%Disable
@echo If objArgument.Count() ^> 0 Then>>%DisableRPVBS%
@echo Drive = objArgument(0)>>%DisableRP
@echo Else>>%DisableRPVBS%
@echo Drive = "">>%DisableRPVBS%
@echo End If>>%DisableRPVBS%
@echo Set obj = GetObject("winmgmts:{imper
@echo If (obj.Disable(Drive)) = 0 Then>>%DisableRPVBS%
@echo wscript.Echo "Y">>%DisableRPVBS%
@echo Else>>%DisableRPVBS%
@echo wscript.Echo "N">>%DisableRPVBS%
@echo End If>>%DisableRPVBS%
for /f "Tokens=*" %%d in ('cscript //nologo %DisableRPVBS% %drive%') do (
set OK=%%d
)
del /q %DisableRPVBS%
endlocal&set %2=%OK%
Or net stop wuauserv
Use this in a batch file to do the following:
Turn off Windows system restore
Turn off Windows automatic updates
Reboot Computer
@echo off
reg add "HKLM\Software\Microsoft\W indows NT\CurrentVersion\SystemRe store" /v DisableSR /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\W indows\Cur rentVersio n\WindowsU pdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\W indows\Cur rentVersio n\WindowsU pdate\Auto Update" /v AUState /t REG_DWORD /d 7 /f
shutdown -r -f -t 2
Turn off Windows system restore
Turn off Windows automatic updates
Reboot Computer
@echo off
reg add "HKLM\Software\Microsoft\W
reg add "HKLM\Software\Microsoft\W
reg add "HKLM\Software\Microsoft\W
shutdown -r -f -t 2
Silly_Burrito: I think stopping the "wauserv" Windows Update service using SC or NET STOP will only disable Windows Updates for the current boot. I think they will re-enable themselves at the next reboot, as the services would restart.
True, but if you put that in a batch file in the Startup folder, it'll work. I do that to map a stubborn network drive and it works nicely.
To disable Automatic Updates.
Sets the Startup type to Disabled, and stops the service
- - -
sc config wuauserv start= disabled
- - -
Turn offSystem Restore service
- - -
sc config srservice start= disabled
- - -
Sets the Startup type to Disabled, and stops the service
- - -
sc config wuauserv start= disabled
- - -
Turn offSystem Restore service
- - -
sc config srservice start= disabled
- - -
ASKER
OK, I'm thouroughly confused now. Does anyone have the short answer for getting all of those accomplished in a single batch file?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
shutdown -r -f