Solved

scripting batch file commands

Posted on 2006-06-16
10
2,015 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:tedpenner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 23

Expert Comment

by:basicinstinct
ID: 16924383
reboot computer is

shutdown -r -f
0
 
LVL 5

Expert Comment

by:Silly_Burrito
ID: 16924528
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%\DisableRP_%RANDOM%.VBS"
set OK=N
@echo Set objArgument = Wscript.Arguments>%DisableRPVBS%
@echo If objArgument.Count() ^> 0 Then>>%DisableRPVBS%
@echo Drive =  objArgument(0)>>%DisableRPVBS%
@echo Else>>%DisableRPVBS%
@echo Drive = "">>%DisableRPVBS%
@echo End If>>%DisableRPVBS%
@echo Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")>>%DisableRPVBS%
@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%
0
 
LVL 5

Expert Comment

by:Silly_Burrito
ID: 16924550
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 5

Expert Comment

by:Silly_Burrito
ID: 16924556
Or net stop wuauserv
0
 
LVL 10

Expert Comment

by:GuruGary
ID: 16924607
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\Windows NT\CurrentVersion\SystemRestore" /v DisableSR /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUState /t REG_DWORD /d 7 /f
shutdown -r -f -t 2
0
 
LVL 10

Expert Comment

by:GuruGary
ID: 16924626
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.
0
 
LVL 5

Expert Comment

by:Silly_Burrito
ID: 16925104
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.
0
 
LVL 34

Expert Comment

by:sramesh2k
ID: 16925214
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
- - -

0
 

Author Comment

by:tedpenner
ID: 16931255
OK, I'm thouroughly confused now.  Does anyone have the short answer for getting all of those accomplished in a single batch file?
0
 
LVL 10

Accepted Solution

by:
GuruGary earned 500 total points
ID: 16931289
Yes, my post accomplishes all the tasks in a single batch file.
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\Windows NT\CurrentVersion\SystemRestore" /v DisableSR /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUState /t REG_DWORD /d 7 /f
shutdown -r -f -t 2
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you build your web application in Visual Studio you'll get at least a few binaries, or .DLL, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is request…
There are 2 things you must have in order to connect to the internet behind a router, The "Gateway IP" of the router, which is usually something like 192.168.xxx.1, I've seen routers with default values of: 192.168.0.1, 192.168.1.1, 192.168.11.1, …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question