本人从华大科技下载一自动升级批处理文件,其中语句如rmdir /S /Q %mhnet% 2>NUL 1>NUL中两个>NUL是何意思呢?不是很明白,请教高手赐教,谢了!
---------- Edited by willsort  ----------
修改原标题:请教:批处理文件语句问题?
---------- Edited by willsort ----------
请教:批处理文件语句问题?
原文件如下:
@echo offrem 使用介绍
rem 功能:试图设置自动连接华科大Windows Update服务器
rem 先进行服务检查,没有安装服务的机器先安装服务,重启动后再修改设置
echo  For Windows 2000,Windows XP,Windows 2003 only. 
echo  只在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 创建临时文件夹
set mhnet=%temp%\mhnet
rmdir /S /Q %mhnet% 2>NUL 1>NUL
mkdir %mhnet%
rem 系统语言环境判断
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  本程序专为设置华科大 Windows Automatic Updates 服务
) else (
 echo  This will setup HUST Windows Automatic Updates Services
)
start readme.txt
rem 检查配套文件完整性
call :AllFiles
rem 检查属于NT系列
call :CheckSystem
rem 检查拥有管理员权限
call :CheckAdmin
rem 检查Automatic Updates服务是否正常安装
call :CheckService
call :HUSTRegImport
if %Language%==Chinese (
 echo  程序讨论,欢迎到 bbs.whnet.edu.cn security版
 echo  程序结束
) else (
 echo  We welcome you to press your opinion on  bbs.whnet board:security
 echo  Program Exit
)
pause
set mhnet=
set patchfile=
set downloadurl=
goto :eof
exit
:ends
rem 主函数结束
rem *************************
rem *************************
rem 导入:HUSTRegImport
rem *************************
rem *************************
:HUSTRegImport
ECHO  备份注册表(Backup Reg) %temp%
pushd %temp%
set BakFile1=AutoUpdateBak1.reg
set BakFile2=AutoUpdateBak2.reg
if exist %BakFile1% (
 ECHO  已经安装了本补丁,按任意键删除原有备份
 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  正在停止WindowsUpdate服务(Stopping Update service)......
net stop wuauserv >NUL 2>NUL
ECHO  正在修改注册表操作(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://windowsupdate.hust.edu.cn" /f >NUL
reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v WUStatusServer /t REG_SZ /d "http://windowsupdate.hust.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 服务自动启动
ECHO  设置服务为自动启动(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  正在重新启动WindowsUpdate服务(Starting Update Service)......
net start bits >NUL 2>NUL 
net start wuauserv >NUL 2>NUL
goto :eof
rem *************************
rem *************************
rem 停止/删除服务函数
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  系统服务: %SrvName% *没找到*
 ) else (
  echo  System Service: %SrvName% Not Found
 )
)
goto :eof
rem *************************
rem *************************
rem 判断是否NT系列系统,win9x系统则退出
rem *************************
rem *************************
:CheckSystem
if NOT %OS%==Windows_NT (
 if %Language%==Chinese (
  echo  本程序专为中文/英文版本的Win2000,WinXP,Win2003设计
  echo  Windows 95, Windows 98, Windows ME的用户不必运行
  echo  程序退出。
 ) 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  用户使用基于WindowsNT内核的系统,
 ) else (
  echo  You are using a system based on WindowsNT kernel,
 )
)
goto :eof
rem *************************
rem *************************
rem 判断是否NT系列系统,win9x系统则退出
rem *************************
rem *************************
:CheckAdmin
net user %username%  1> %mhnet%\ifadmin.log
rem 如果不是系统管理员
find "*Administrators " %mhnet%\ifadmin.log >NUL
IF ERRORLEVEL 1 (
 if %Language%==Chinese (
  echo  用户不是系统管理员组成员 ,不能执行相应程序
  echo  请更换有足够权限的用户重新运行本程序
 ) 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  用户属于系统管理员组,
 ) else (
  echo  You have got the right of administrator, 
 )
)
goto :eof
rem *************************
rem *************************
rem 先进行补丁检查,没有安装补丁的机器先安装补丁,重启动后再查杀病毒
rem *************************
rem *************************
:CheckService
rem if %Language%==Chinese (
rem  echo  检查 Automatic Updates 
rem ) else (
rem  echo  Checking Automatic Updates Service
rem )
rem 检查服务的注册表值
reg query "HKLM\SYSTEM\CurrentControlSet\Services" >%mhnet%\Services.log
find "wuauserv" %mhnet%\Services.log >NUL
IF ERRORLEVEL 1 (
 rem 您的计算机未安装Automatic updates服务
 call :InstallService
 pause
 exit
 rem 中止执行
) ELSE (
rem  if %Language%==Chinese (
rem   echo  注册表检查显示您的系统已经安装了wuauserv服务。
rem  ) else (
rem   echo  reg reports that your system has wuauserv service installed
rem  )
)
goto :eof
rem *************************
rem *************************
rem 清空注册表某\Run值
rem *************************
rem *************************
:CleanRun
reg delete HKLM\Software\Microsoft\Windows\CurrentVersion\Run\\%1 /f >NUL
goto :eof
rem *************************
rem *************************
rem 停止不安全服务
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 导入正常注册表的execute文件关联
rem *************************
rem *************************
:Regdefault
reg import regdefault.reg >NUL
goto :eof
rem *************************
rem *************************
rem 安装wuauserv包
rem *************************
rem *************************
:InstallService
rem reg query HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language >%mhnet%\Language.log
rem 中文系统
find "InstallLanguage" %mhnet%\Language.log |find "0804" >NUL
IF NOT ERRORLEVEL 1 (CALL :CNService ) 
rem 英文系统
find "InstallLanguage" %mhnet%\Language.log |find "0409" >NUL
IF NOT ERRORLEVEL 1 (CALL :ENService ) 
rem 其他语言包,以上语言包虽用call调用,但不希望返回
if %Language%==Chinese (
 echo  你并未使用中文/英文操作系统,
 echo  请记下下面显示的InstallLanguage及Default的值,请到微软网站下载相应服务
 echo  程序退出
) 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 微软服务安装网页
pause
exit
goto :eof
rem *************************
rem *************************
rem 中文服务包下载安装
rem *************************
rem *************************
:CNService
set patchfile=WUAU22CHS.msi
set downloadurl=http://windowsupdate.hust.edu.cn/patch/%patchfile%
call <img src="images/smilies/face-smile-big.png" align="absmiddle" border="0">ownload
start %mhnet%\%patchfile%
if %Language%==Chinese (
 echo  安装好服务后重启电脑,再运行本程序
) else (
 echo  Restart your computer when Service installation is done. And run again.
)
pause
exit
goto :eof
rem *************************
rem *************************
rem 英文服务包下载安装
rem *************************
rem *************************
:ENService
set patchfile=WUAU22ENU.msi
set downloadurl=http://windowsupdate.hust.edu.cn/patch/%patchfile%
call <img src="images/smilies/face-smile-big.png" align="absmiddle" border="0">ownload
start %mhnet%\%patchfile%
if %Language%==Chinese (
 echo  安装好服务后重启电脑,再运行本程序
) else (
 echo  Restart your computer when Service installation is done. And run again.
)
pause
exit
goto :eof
rem *************************
rem *************************
rem 检查部分文件完整性
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 下载补丁,用%patchfile%传入文件名
rem *************************
rem *************************
<img src="images/smilies/face-smile-big.png" align="absmiddle" border="0">ownload
 if %Language%==Chinese (
  echo  自动下载 %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  下载成功。
  ) else (
   echo  Download Success
  )
 ) else (
  if %Language%==Chinese (
   echo  下载失败。程序退出
  ) else (
   echo  Download Failed. Terminated
  )
  pause
  exit
 )
 popd
goto :eof
rem ----- this is the end of this batch file -------
 Last edited by willsort on 2006-5-13 at 18:28 ]
 
The two >NUL in the statement "rmdir /S /Q %mhnet% 2>NUL 1>NUL" are used to redirect error output and standard output respectively to the null device. Specifically, 2>NUL redirects the error output (standard error) to the null device, and 1>NUL redirects the standard output to the null device, which means that the error and output information generated by the rmdir command will not be displayed on the screen.
The following is the translated content of the entire batch file related part:
I downloaded an automatic upgrade batch file from Huada Technology. What does the two >NUL in the statement like rmdir /S /Q %mhnet% 2>NUL 1>NUL mean? I don't understand very well. Please ask experts for advice, thank you!
---------- Edited by willsort  ----------
Modified original title: Ask: Batch file statement problem?
---------- Edited by willsort ----------
Ask: Batch file statement problem?
The original file is as follows:
@echo offrem Usage introduction
rem Function: Try to set up automatic connection to Huazhong University of Science and Technology Windows Update server
rem First perform service check, for the machine without the installed service, install the service first, restart and then modify the settings
echo  For Windows 2000,Windows XP,Windows 2003 only. 
echo  Only applicable on 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 System language environment judgment
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 designed to set up Huazhong University of Science and Technology Windows Automatic Updates service
) else (
 echo  This will setup HUST Windows Automatic Updates Services
)
start readme.txt
rem Check the integrity of supporting files
call :AllFiles
rem Check if it belongs to NT series
call :CheckSystem
rem Check if it has administrator privileges
call :CheckAdmin
rem Check if the Automatic Updates service is normally installed
call :CheckService
call :HUSTRegImport
if %Language%==Chinese (
 echo  For program discussion, welcome to bbs.whnet.edu.cn security version
 echo  Program ends
) else (
 echo  We welcome you to press your opinion on  bbs.whnet board:security
 echo  Program Exit
)
pause
set mhnet=
set patchfile=
set downloadurl=
goto :eof
exit
:ends
rem Main function ends
rem *************************
rem *************************
rem Import: HUSTRegImport
rem *************************
rem *************************
:HUSTRegImport
ECHO  Backup registry (Backup Reg) %temp%
pushd %temp%
set BakFile1=AutoUpdateBak1.reg
set BakFile2=AutoUpdateBak2.reg
if exist %BakFile1% (
 ECHO  This patch has been 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 operation (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://windowsupdate.hust.edu.cn" /f >NUL
reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v WUStatusServer /t REG_SZ /d "http://windowsupdate.hust.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 Set the service to start automatically
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 Stop/delete service function
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 Judge whether it is an NT series system, and exit for win9x system
rem *************************
rem *************************
:CheckSystem
if NOT %OS%==Windows_NT (
 if %Language%==Chinese (
  echo  This program is specially designed for Chinese/English version of Win2000, WinXP, Win2003
  echo  Users of Windows 95, Windows 98, Windows ME do not need to run
  echo  Program exit.
 ) 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 WindowsNT kernel,
 ) else (
  echo  You are using a system based on WindowsNT kernel,
 )
)
goto :eof
rem *************************
rem *************************
rem Judge whether it is an NT series system, and exit for win9x system
rem *************************
rem *************************
:CheckAdmin
net user %username%  1> %mhnet%\ifadmin.log
rem If it is 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 execute the corresponding program
  echo  Please change to a user with sufficient privileges to re-run this program
 ) 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 perform patch check, for the machine without installed patch, install the patch first, restart and then kill the virus
rem *************************
rem *************************
:CheckService
rem if %Language%==Chinese (
rem  echo  Checking 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 Your computer has not installed the Automatic updates service
 call :InstallService
 pause
 exit
 rem Abort execution
) ELSE (
rem  if %Language%==Chinese (
rem   echo  Registry check shows that your system has installed the wuauserv service.
rem  ) else (
rem   echo  reg reports that your system has wuauserv service installed
rem  )
)
goto :eof
rem *************************
rem *************************
rem Clear a \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 service
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 of the normal registry
rem *************************
rem *************************
:Regdefault
reg import regdefault.reg >NUL
goto :eof
rem *************************
rem *************************
rem Install 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 are called by call, but do not want to return
if %Language%==Chinese (
 echo  You are not using a Chinese/English operating system,
 echo  Please write down the displayed InstallLanguage and Default values below, and download the corresponding service from the Microsoft website
 echo  Program exit
) 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 web page
pause
exit
goto :eof
rem *************************
rem *************************
rem Chinese service package download and installation
rem *************************
rem *************************
:CNService
set patchfile=WUAU22CHS.msi
set downloadurl=http://windowsupdate.hust.edu.cn/patch/%patchfile%
call :Download
start %mhnet%\%patchfile%
if %Language%==Chinese (
 echo  Restart the computer after installing the service, and then run this program
) else (
 echo  Restart your computer when Service installation is done. And run again.
)
pause
exit
goto :eof
rem *************************
rem *************************
rem English service package download and installation
rem *************************
rem *************************
:ENService
set patchfile=WUAU22ENU.msi
set downloadurl=http://windowsupdate.hust.edu.cn/patch/%patchfile%
call :Download
start %mhnet%\%patchfile%
if %Language%==Chinese (
 echo  Restart the computer after installing the service, and then run this program
) else (
 echo  Restart your computer when Service installation is done. And run again.
)
pause
exit
goto :eof
rem *************************
rem *************************
rem Check the integrity 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 in file name with %patchfile%
rem *************************
rem *************************
:Download
 if %Language%==Chinese (
  echo  Automatically download %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 exit
  ) else (
   echo  Download Failed. Terminated
  )
  pause
  exit
 )
 popd
goto :eof
rem ----- this is the end of this batch file -------
 Last edited by willsort on 2006-5-13 at 18:28 ]