Board logo

标题: [系统相关] [已解决]学·知-讨论-系统封装中,Microsoft Security Essentials安装批处理优化 [打印本页]

作者: 34205    时间: 2015-1-26 11:44     标题: [已解决]学·知-讨论-系统封装中,Microsoft Security Essentials安装批处理优化

本帖最后由 34205 于 2015-1-26 21:13 编辑

如题,目的:
1、系统封装中,MSE封装于部署前重新部署会出现变英文现象,
2、标题为优化,是因为本论坛已经有老帖有相关的代码,在它基础上优化而已,
3、我也是新手,贴出来交流,看看还有没有比较好的办法,或者可以改进这些重复的代码

       微软安全套装 Microsoft Security Essentials 安装辅助
  1. @echo off
  2. color 2F
  3. MODE con: COLS=72 LINES=24
  4. Title        微软安全套装 Microsoft Security Essentials 安装辅助
  5. :Start
  6. cls
  7. echo.
  8. echo ========================================================================
  9. echo ========***************************************************=============
  10. echo.
  11. echo         微软安全套装 Microsoft Security Essentials 安装辅助
  12. echo.
  13. echo ========***************************************************=============
  14. echo ========================================================================
  15. echo.
  16. echo.
  17. echo.
  18. echo                                                ==By 35205==
  19. echo.
  20. echo.
  21. echo.
  22. Ping -n 4 127.1>nul
  23. :SetSys
  24. REM 判断系统类型========
  25. :renamebat
  26. if exist %windir%\SysWOW64\*.* (set x=x64&set xM=64 ) else (set x=x86&set xM=32 )
  27. goto Setup
  28. REM 安装文件==========================================================================================================================================
  29. :Setup
  30. :SetupChoice
  31. echo.
  32. echo.
  33. echo.
  34. echo.
  35. echo.
  36. echo.
  37. echo.
  38. echo ========================================================================
  39. echo.
  40. echo   (1)是 / (2)否 开始安装? 请选择按 1 / 2 / 3(下载地址):
  41. echo.
  42. echo.
  43. echo ========================================================================
  44. echo.
  45. set /p SetupChoice=
  46. if "%SetupChoice%"=="1" goto SetupChoice_Y
  47. if "%SetupChoice%"=="2" goto SetupChoice_N
  48. if "%SetupChoice%"=="3" goto SetupChoice_URL
  49. goto SetupChoice_N
  50. :SetupChoice_Y
  51. REM goto SetupChoice_Y_
  52. REM========================文件命名==========================================
  53. echo .
  54. Set Installname=Microsoft MSE-MSEInstall.exe
  55. ren "%Installname%" mseinstall.exe
  56. Set mpam-fex64name=Microsoft MSE-mpam-fex64.exe
  57. ren "%mpam-fex64name%" mpam-fex64.exe
  58. Set mpam-fename=Microsoft MSE-mpam-fe.exe
  59. ren "%mpam-fename%" mpam-fe.exe
  60. Set nis_fullname=Microsoft MSE-nis_full.exe
  61. ren "%nis_fullname%" nis_full.exe
  62. Set mpam-dname=Microsoft MSE-mpam-d.exe
  63. ren "%mpam-dname%" mpam-d.exe
  64. :SetupChoice_Y_
  65. echo.
  66. echo ========================================================================
  67. echo.
  68. echo      请确认4个安装包已经按照如下格式放置
  69. echo.
  70. echo.
  71. echo   目录\
  72. echo X86\mseinstall.exe
  73. echo    \mpam-fex86.exe
  74. echo    \nis_full.exe
  75. echo    \mpam-d.exe
  76. echo X64\mseinstall.exe
  77. echo    \mpam-fex64.exe
  78. echo    \nis_full.exe
  79. echo    \mpam-d.exe
  80. echo.
  81. echo.
  82. echo ========================================================================
  83. echo.
  84. echo.
  85. ping -n 4 127.1 >nul
  86. echo.
  87. echo.
  88. Rem 开始安装....
  89. echo 开始安装..................
  90. if exist "%~dp0\mseinstall.exe" (echo 找到文件.mseinstall... &"%~dp0\mseinstall.exe" /s /runwgacheck /o &echo 已经安装.mseinstall...) else (echo 无法找到 mseinstall.exe .......)
  91. if %x%#==x64# (goto MPAM-64) else (goto MPAM-32)
  92. :MPAM-64
  93. if exist "%~dp0\mpam-fex64.exe" (echo 找到文件.mpam-fex64... &"%~dp0\mpam-fex64.exe" /q &echo 已经安装.mpam-fex64...) else (echo 无法找到 %~dp0\mpam-fex64.exe .......)
  94. goto Installfull
  95. :MPAM-32
  96. if exist "%~dp0\mpam-fe.exe" (echo 找到文件.mpam-fe... &"%~dp0\mpam-fe.exe" /q &echo 已经安装.mpam-fe...) else (echo 无法找到 %~dp0\mpam-fe.exe .......)
  97. goto Installfull
  98. :Installfull
  99. if exist "%~dp0\nis_full.exe" (echo 找到文件.nis_full... &"%~dp0\nis_full.exe" /q &echo 已经安装.nis_full...)  else (echo 无法找到 nis_full.exe .......)
  100. if exist "%~dp0\mpam-d.exe" (echo 找到文件.mpam-d... &"%~dp0\mpam-d.exe" /q &echo 已经安装.mpam-d...) else (echo 无法找到 mpam-d.exe .......)
  101. ping -n 3 127.1>nul
  102. Cd %ProgramFiles%
  103. if exist "%ProgramFiles%\Microsoft Security Client\msseces.exe" (Echo 找到Msseces开始启动... &goto StartMsseces) else (echo 无法找到 Msseces....... &goto REG_Set)
  104. :StartMsseces
  105. Echo 找到Msseces开始启动.....
  106. start "" "%ProgramFiles%\Microsoft Security Client\msseces.exe"
  107. Echo 找到Msseces开始启动........
  108. ping -n 5 127.0.0.1 >nul 2>nul
  109. Echo 找到Msseces开始启动............
  110. start "" "%ProgramFiles%\Microsoft Security Client\msseces.exe" -hide -runkey
  111. ::::::Echo ..........................
  112. ::::::执行立即更新病毒库参数可以用下面的命令
  113. ::::::Echo 执行立即更新病毒库N...
  114. ::::::start "" "%ProgramFiles%\Microsoft Security Client\msseces.exe" /update
  115. ::::::执行更新病毒库后执行快速扫描可以用下面的命令
  116. ::::::Echo 执行更新病毒库后执行快速扫描N...
  117. ::::::start "" "%ProgramFiles%\Microsoft Security Client\msseces.exe" /updateandquickscan
  118. ::::::将Microsoft Security Essentials添加到防火墙允许列表可以用下面的命令
  119. ::::::Echo 将Microsoft Security Essentials添加到防火墙N...
  120. ::::::netsh firewall add allowedprogram program="%ProgramFiles%\Microsoft Security Client\msseces.exe" name= "Microsoft Security Essentials" mode=enable
  121. Echo.
  122. echo.
  123. echo.
  124. echo 启动完成...
  125. ping -n 3 127.1>nul
  126. echo.
  127. GOTO REG_Set
  128. :SetupChoice_N
  129. echo.
  130. echo 不安装....
  131. echo.
  132. goto Out
  133. REM 安装文件
  134. :SetupChoice_URL
  135. set MseInstall=正在下载 Microsoft Security Essentials(微软安全套装 %xM% 位)简体中文版安装包...
  136. echo.
  137. echo %MseInstall%
  138. echo MseInstall
  139. start /wait "iexplorer" http://download.microsoft.com/download/1/E/D/1ED80C09-218B-44D7-B72D-E1451634E72D/ZHCN/amd64/MSEInstall.exe
  140. Pause
  141. set MseMPAM-FE=正在下载 Microsoft Security Essentials(微软安全套装 %xM% 位)最新病毒定义库...
  142. echo.
  143. echo %MseMPAM-FE%
  144. echo MseMPAM-FE
  145. start /wait "iexplorer" http://download.microsoft.com/download/DefinitionUpdates/mpam-fex64.exe
  146. PAUSE
  147. set MseNIS_FULL=正在下载 Microsoft Security Essentials(微软安全套装 %xM% 位)最新病毒定义增量库...
  148. echo.
  149. echo %MseNIS_FULL%
  150. echo MseNIS_FULL
  151. start /wait "iexplorer" http://download.microsoft.com/download/DefinitionUpdates/amd64/nis_full.exe
  152. Pause
  153. set MseMPAM-D=正在下载 Microsoft Security Essentials(微软安全套装 %xM% 位)最新网络安全定义库...
  154. echo.
  155. echo %MseMPAM-D%
  156. echo MseMPAM-D
  157. start /wait "iexplorer" http://download.microsoft.com/download/DefinitionUpdates/amd64/mpam-d.exe
  158. PAUSE
  159. Goto setup
  160. ==========================================================================================================================================
  161. Rem 优化设置
  162. :REG_Set
  163. echo.
  164. Ping -n 2 127.1>nul
  165. rem Microsoft Security Essentials 优化设置=============================================================================================================
  166. :Reg_set_ask
  167. echo.
  168. echo ========================================================================
  169. echo.
  170. echo (1)是/(2)否 进行Microsoft Security Essentials优化设置?请选择按 1 / 2 :
  171. echo.
  172. echo.
  173. echo ========================================================================
  174. echo.
  175. set /p Reg_set_ask=
  176. if “%Reg_set_ask%”==“1” goto Reg_set_ask_Y
  177. if “%Reg_set_ask%”==“2” goto Reg_set_ask_N
  178. goto Reg_set_ask_N
  179. :Reg_set_ask_Y
  180. :排除的文件类型(示例)
  181. echo .......................
  182. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Extensions" /v "cab" /t REG_DWORD /d 0 /f >nul 2>nul
  183. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Extensions" /v "rar" /t REG_DWORD /d 0 /f >nul 2>nul
  184. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Extensions" /v "zip" /t REG_DWORD /d 0 /f >nul 2>nul
  185. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Extensions" /v "z" /t REG_DWORD /d 0 /f >nul 2>nul
  186. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Extensions" /v "7z" /t REG_DWORD /d 0 /f >nul 2>nul
  187. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Extensions" /v "iso" /t REG_DWORD /d 0 /f >nul 2>nul
  188. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Extensions" /v "img" /t REG_DWORD /d 0 /f >nul 2>nul
  189. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Extensions" /v "wim" /t REG_DWORD /d 0 /f >nul 2>nul
  190. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Extensions" /v "vhd" /t REG_DWORD /d 0 /f >nul 2>nul
  191. REM :排除文件和位置(示例)
  192. echo .......................
  193. REM reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Paths" /v "E:\\(示例)" /t REG_DWORD /d 0 /f >nul 2>nul
  194. REM :排除进程名(示例)
  195. echo .......................
  196. REM reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Processes" /v "(示例).exe" /t REG_DWORD /d 0 /f >nul 2>nul
  197. :隔离项目在一个月后自动删除(示例)
  198. echo .......................
  199. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Quarantine" /v "PurgeItemsAfterDelay" /t REG_DWORD /d 30 /f >nul 2>nul
  200. :控制 CPU 使用率限制30%(示例)
  201. echo .......................
  202. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Scan" /v "AvgCPULoadFactor" /t REG_DWORD /d 30 /f >nul 2>nul
  203. :不扫描存档文件(示例)
  204. echo .......................
  205. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Scan" /v "DisableArchiveScanning" /t REG_DWORD /d 1 /f >nul 2>nul
  206. :严重级别(删除操作)(示例)
  207. echo .......................
  208. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Threats\ThreatSeverityDefaultAction" /v "5" /t REG_DWORD /d 3 /f >nul 2>nul
  209. :高级别(隔离操作)(示例)
  210. echo .......................
  211. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Threats\ThreatSeverityDefaultAction" /v "4" /t REG_DWORD /d 2 /f >nul 2>nul
  212. :中级别(隔离操作)(示例)
  213. echo .......................
  214. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Threats\ThreatSeverityDefaultAction" /v "3" /t REG_DWORD /d 2 /f >nul 2>nul
  215. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Threats\ThreatSeverityDefaultAction" /v "2" /t REG_DWORD /d 2 /f >nul 2>nul
  216. :低级别(允许操作)(示例)
  217. echo .......................
  218. reg add "HKLM\SOFTWARE\Microsoft\Microsoft Antimalware\Threats\ThreatSeverityDefaultAction" /v "1" /t REG_DWORD /d 6 /f >nul 2>nul
  219. echo .......................
  220. echo.
  221. echo Microsoft Security Essentials 优化设置完成....
  222. echo.
  223. ping -n 2 127.1>nul
  224. echo.
  225. goto Out
  226. :Reg_set_ask_N
  227. echo.
  228. echo Microsoft Security Essentials 不优化....
  229. echo.
  230. ping -n 2 127.1>nul
  231. echo.
  232. echo.
  233. goto Out
  234. rem Microsoft Security Essentials 优化设置=================================================================================================================
  235. :Out
  236. echo.
  237. echo.
  238. echo.
  239. echo 准备退出.....................................
  240. echo.
  241. ping -n 5 127.1>nul
  242. exit
复制代码
[/hide]
作者: DAIC    时间: 2015-1-26 12:40

50到52行的双引号是不是写错了
作者: 34205    时间: 2015-1-26 14:53

本帖最后由 34205 于 2015-1-26 14:57 编辑

回复 2# DAIC


    运行了可以运行,可能是其中一种写法吧(我也是新手,搬运的),它不是判断返回的错误值,而是直接判断你输入的是 1  还是2  还是3
作者: DAIC    时间: 2015-1-26 15:19

回复 3# 34205


    能告诉我从哪里搬运的吗?我想知道他问什么使用中文双引号。
作者: 34205    时间: 2015-1-26 16:18

本帖最后由 34205 于 2015-1-26 16:19 编辑

回复 4# DAIC


    你不说我还真没有注意,这几个是中文输入法的,可是我也试了我的Bat测试选择不同的123也是可以的,看来从严谨的角度上来说,还是把中文引号改成英文的更安全 。之前的文章没有安排选择的代码。搬运,引用 http://www.bathome.net/viewthrea ... curity%2BEssentials
作者: gwaijyut    时间: 2024-5-30 23:42

感谢分享,非常管用!




欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2