![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-07 19:04 |
48,041 topics / 350,128 posts / today 3 new / 48,252 members |
| DOS批处理 & 脚本技术(批处理室) » System Patch Updates |
| Printable Version 2,890 / 5 |
| Floor1 3932575 | Posted 2007-04-24 05:10 |
| 新手上路 Posts 3 Credits 4 | |
|
I wonder if anyone has tried a batch file for system patch updates?
In an internal network, use one machine as the server and let it update all the machines on the network, and do it automatically (or at startup). It can automatically determine whether a machine has already been updated. If it has already been updated, it won't run; if it hasn't, it will run. Each time it runs an update program, it records that filename into a specified file....... OK? |
|
| Floor2 junzai | Posted 2007-04-30 01:29 |
| 新手上路 Posts 7 Credits 16 | |
|
@echo off
rem XJNU WINDOWS UPDATE SERVICES rem History echo For Windows 2000,Windows XP,Windows 2003 only. echo Only applicable to Windows 2000,Windows XP,Windows 2003 echo For Normal user only (computer that runs every day) set Server=0 rem Server=1 pause cls rem Create temporary folder set mhnet=%temp%\mhnet rmdir /S /Q %mhnet% 2>NUL 1>NUL mkdir %mhnet% rem Check system language environment reg query HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language >%mhnet%\Language.log find "Default" %mhnet%\Language.log |find "0804" >NUL IF NOT ERRORLEVEL 1 ( set Language=Chinese ) else ( set Language=English ) if %Language%==Chinese ( echo This program is specially made to set up Xinjiang Normal University's Windows Automatic Updates service ) else ( echo This will setup XJNU Windows Automatic Updates Services ) start readme.txt rem Check completeness of required files call :AllFiles rem Check that it belongs to the NT series call :CheckSystem rem Check for administrator privileges call :CheckAdmin rem Check whether the Automatic Updates service is properly installed call :CheckService call :SCAURegImport if %Language%==Chinese ( echo Welcome echo Program finished ) else ( echo We welcome you echo Program Exit ) pause set mhnet= set patchfile= set downloadurl= goto :eof exit :ends rem End of main function rem ************************* rem ************************* rem Import: SCAURegImport rem ************************* rem ************************* :SCAURegImport ECHO Backing up registry(Backup Reg) %temp% pushd %temp% set BakFile1=AutoUpdateBak1.reg set BakFile2=AutoUpdateBak2.reg if exist %BakFile1% ( ECHO This patch is already installed, press any key to delete the original backup PAUSE delete %BakFile1% /f /q >NUL 2>NUL delete %BakFile2% /f /q >NUL 2>NUL ) popd pushd %mhnet% reg EXPORT "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" %BakFile1% 1>NUL reg EXPORT "HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate" %BakFile2% 1>NUL move %BakFile1% %temp% >NUL move %BakFile2% %temp% >NUL set BakFile1= set BakFile2= popd ECHO Stopping WindowsUpdate service(Stopping Update service)...... net stop wuauserv >NUL 2>NUL ECHO Modifying registry(Modifying Registry)...... ECHO Y |reg DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /va /f >NUL reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v WUServer /t REG_SZ /d "http://wsus.xjnu.edu.cn" /f >NUL reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v WUStatusServer /t REG_SZ /d "http://wsus.xjnu.edu.cn" /f >NUL reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v NoAutoRebootWithLoggedOnUsers /t REG_DWORD /d 1 /f >NUL reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v NoAutoUpdate /t REG_DWORD /d 0 /f >NUL reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v RescheduleWaitTime /t REG_DWORD /d 1 /f >NUL reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v ScheduledInstallDay /t REG_DWORD /d 0 /f >NUL reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v UseWUServer /t REG_DWORD /d 1 /f >NUL if %Server%==1 ( ECHO Automatic Updates Service installed for server reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v AUOptions /t REG_DWORD /d 4 /f >NUL reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v ScheduledInstallTime /t REG_DWORD /d 11 /f >NUL ) else ( ECHO Automatic Updates Service installed for non-server reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v AUOptions /t REG_DWORD /d 2 /f >NUL reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v ScheduledInstallTime /t REG_DWORD /d 12 /f >NUL ) rem Service auto-start ECHO Set service to automatic start(Set service to automatic start) reg add HKLM\SYSTEM\CurrentControlSet\Services\wuauserv /v Start /t REG_DWORD /d 2 /f >NUL reg add HKLM\SYSTEM\CurrentControlSet\Services\BITS /v Start /t REG_DWORD /d 2 /f >NUL ECHO Restarting WindowsUpdate service(Starting Update Service)...... net start bits >NUL 2>NUL net start wuauserv >NUL 2>NUL goto :eof rem ************************* rem ************************* rem Function to stop/delete service rem ************************* rem ************************* :StopService set SrvName=%1 net stop %SrvName% >NUL >NUL2 reg query HKLM\SYSTEM\CurrentControlSet\Services\\%SrvName% >NUL if not errorlevel 1 ( reg delete HKLM\SYSTEM\CurrentControlSet\Services\\%SrvName% /f >NUL ) ELSE ( if %Language%==Chinese ( echo System service: %SrvName% *not found* ) else ( echo System Service: %SrvName% Not Found ) ) goto :eof rem ************************* rem ************************* rem Determine whether it is an NT-series system; exit for win9x systems rem ************************* rem ************************* :CheckSystem if NOT %OS%==Windows_NT ( if %Language%==Chinese ( echo This program is specially designed for Chinese/English versions of Win2000,WinXP,Win2003 echo Users of Windows 95, Windows 98, Windows ME do not need to run it echo Program exiting. ) else ( echo Design for Win2k,WinXP,Win2003 with Chinese or English version only. echo Windows 95,Windows 98, Windows ME will not be troubled by this bug. echo Thank you for checking. Please deliver this to someone who need it. ) pause exit ) else ( if %Language%==Chinese ( echo The user is using a system based on the WindowsNT kernel, ) else ( echo You are using a system based on WindowsNT kernel, ) ) goto :eof rem ************************* rem ************************* rem Determine whether it is an NT-series system; exit for win9x systems rem ************************* rem ************************* :CheckAdmin net user "%username%" 1> %mhnet%\ifadmin.log rem If not a system administrator find "*Administrators " %mhnet%\ifadmin.log >NUL IF ERRORLEVEL 1 ( if %Language%==Chinese ( echo The user is not a member of the system administrator group and cannot run the corresponding program echo Please switch to a user with sufficient privileges and run this program again ) else ( echo This program require administrator right to continue echo Please switch user and try again ) pause exit goto :eof ) else ( if %Language%==Chinese ( echo The user belongs to the system administrator group, ) else ( echo You have got the right of administrator, ) ) goto :eof rem ************************* rem ************************* rem First check the patch; machines without the patch installed should install it first, then after reboot check and kill the virus rem ************************* rem ************************* :CheckService rem if %Language%==Chinese ( rem echo Check Automatic Updates rem ) else ( rem echo Checking Automatic Updates Service rem ) rem Check the registry value of the service reg query "HKLM\SYSTEM\CurrentControlSet\Services" >%mhnet%\Services.log find "wuauserv" %mhnet%\Services.log >NUL IF ERRORLEVEL 1 ( rem Automatic updates service is not installed on your computer call :InstallService pause exit rem Abort execution ) ELSE ( rem if %Language%==Chinese ( rem echo Registry check shows that wuauserv service is already installed on your system. rem ) else ( rem echo reg reports that your system has wuauserv service installed rem ) ) goto :eof rem ************************* rem ************************* rem Clear a certain \Run value in the registry rem ************************* rem ************************* :CleanRun reg delete HKLM\Software\Microsoft\Windows\CurrentVersion\Run\\%1 /f >NUL goto :eof rem ************************* rem ************************* rem Stop unsafe services rem ************************* rem ************************* :StopUnSafeSrv rem net stop %1 >NUL reg add HKLM\SYSTEM\CurrentControlSet\Services\\%1 /v Start /t REG_DWORD /d 0x3 /f >NUL goto :eof rem ************************* rem ************************* rem Import the execute file association from a normal registry rem ************************* rem ************************* :Regdefault reg import regdefault.reg >NUL goto :eof rem ************************* rem ************************* rem Install the wuauserv package rem ************************* rem ************************* :InstallService rem reg query HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language >%mhnet%\Language.log rem Chinese system find "InstallLanguage" %mhnet%\Language.log |find "0804" >NUL IF NOT ERRORLEVEL 1 (CALL :CNService ) rem English system find "InstallLanguage" %mhnet%\Language.log |find "0409" >NUL IF NOT ERRORLEVEL 1 (CALL :ENService ) rem Other language packs; although the above language packs use call, return is not desired if %Language%==Chinese ( echo You are not using a Chinese/English operating system, echo Please write down the InstallLanguage and Default values shown below, then go to the Microsoft website to download the corresponding service echo Program exiting ) else ( echo You are not using windows with Chinese/English language echo We suggest you download the service from microsoft website. echo Please write down the InstallLanguage & Default value for later use. echo program terminated ) find "InstallLanguage" %mhnet%\Languate.log start http://www.microsoft.com/downloads/details.aspx?FamilyID=799432fb-c196-4f01-8cce-4f9ea58d6177&DisplayLang=en rem Microsoft service installation webpage pause exit goto :eof rem ************************* rem ************************* rem Download and install Chinese service package rem ************************* rem ************************* :CNService set patchfile=WUAU22CHS.msi set downloadurl=http://wsus.xjnu.edu.cn/wsus/%patchfile% call :Download start %mhnet%\%patchfile% if %Language%==Chinese ( echo After installing the service, restart the computer, then run this program again ) else ( echo Restart your computer when Service installation is done. And run again. ) pause exit goto :eof rem ************************* rem ************************* rem Download and install English service package rem ************************* rem ************************* :ENService set patchfile=WUAU22ENU.msi set downloadurl=http://wsus.xjnu.edu.cn/wsus/%patchfile% call :Download start %mhnet%\%patchfile% if %Language%==Chinese ( echo After installing the service, restart the computer, then run this program again ) else ( echo Restart your computer when Service installation is done. And run again. ) pause exit goto :eof rem ************************* rem ************************* rem Check completeness of some files rem ************************* rem ************************* :AllFiles if not exist reg.exe ( echo reg.exe NOT FOUND pause exit ) else ( copy reg.exe %mhnet% /y >NUL ) if not exist wget.exe ( echo wget.exe NOT FOUND pause exit ) else ( copy wget.exe %mhnet% /y >NUL ) goto :eof rem ************************* rem ************************* rem Download patch, pass filename with %patchfile% rem ************************* rem ************************* :Download if %Language%==Chinese ( echo Automatically downloading %downloadurl% ) else ( echo Downloading %downloadurl% ) pushd %mhnet% if exist %patchfile% ( del %patchfile% /f /q >NUL 2>NUL ) wget %downloadurl% IF NOT ERRORLEVEL 1 ( if %Language%==Chinese ( echo Download successful. ) else ( echo Download Success ) ) else ( if %Language%==Chinese ( echo Download failed. Program exiting ) else ( echo Download Failed. Terminated ) pause exit ) popd goto :eof rem ----- this is the end of this batch file ------- |
|
| Floor3 bingxiao20 | Posted 2007-04-30 02:27 |
| 初级用户 Posts 31 Credits 68 | |
|
So awesome... I'll go download it and take a look later...
|
|
| Floor4 huyingbin | Posted 2007-05-29 11:06 |
| 初级用户 Posts 12 Credits 23 | |
|
Awesome
|
|
| Floor5 limouse01 | Posted 2007-12-03 09:03 |
| 新手上路 Posts 2 Credits 4 | |
|
I'll download it and study it a bit
|
|
| Floor6 5872169 | Posted 2008-03-07 17:37 |
| 高级用户 Posts 474 Credits 959 | |
|
Awesome, this must have taken a lot of work!
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |