installbat.in 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. @setlocal enabledelayedexpansion
  2. @echo off
  3. @rem 要求以管理员方式启动
  4. bcdedit >nul
  5. if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto UACAdmin)
  6. :UACPrompt
  7. %1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&exit
  8. exit /B
  9. :UACAdmin
  10. color 0F
  11. @cls
  12. title 【可视柜台应用程序安装脚本】
  13. for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
  14. set "DEL=%%a"
  15. )
  16. cd /d "%~dp0"
  17. @set /a argumentNum=0
  18. @set ret=0
  19. @rem 1 关机 2 重启
  20. @set poweroffPC=0
  21. @set /a installType=0
  22. @set installPure=1
  23. @for %%a in (%*) do set /a argumentNum+=1
  24. @if %argumentNum% gtr 0 (
  25. @echo argument count: %argumentNum%
  26. ) else (
  27. @echo no any arguments
  28. )
  29. @set installType=@INSTALLSCRIPT_TYPE@
  30. @echo [RVCTermianal] ========== Install Start ==========
  31. @echo 安装脚本模式: %installType%
  32. @set ROOT=%cd%
  33. @set rvc_src_path_rvc_dir=%ROOT%\rvc
  34. @set rvc_src_path_Run_dir=%ROOT%\Run
  35. @set rvc_src_path_rvc_res_dir=%rvc_src_path_rvc_dir%\Resources
  36. @set rvc_install_path_root=%HOMEDRIVE%:
  37. @set sysdisk=1
  38. @set lnkPath=spexplorerauto.lnk
  39. @set AutoStartDir=C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
  40. @set AutoStartDir2=C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
  41. @set VS2019MarkFile=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe
  42. @set RVCTerminalDirName=
  43. @set RVCTerminalDirFullPath=
  44. @set RVCCurInstallVersion=
  45. tasklist /nh | find /i "spshell.exe"
  46. @if errorlevel 1 (
  47. @echo [INFO] 可视柜台进程不存在,跳过进程清理
  48. ) else (
  49. @echo [INFO] 检测到可视柜台进程存在,开始清理可视柜台相关进程……
  50. TASKKILL /F /IM spshell.exe
  51. TASKKILL /F /IM guardian.exe
  52. TASKKILL /F /IM cefclient.exe
  53. @for /f "tokens=1,2 delims= " %%a in ('tasklist /m ^| findstr "sphost.exe"') do (
  54. @echo name=%%a, PID = %%b, and will kill it.
  55. TASKKILL /F /PID %%a
  56. )
  57. )
  58. @rem 如果是非生产环境并且且是开发者的电脑在安装版本,那么部分公共的设置不生效,例如壁纸,开机自启动
  59. @if %installType% equ 0 (
  60. @if exist "%VS2019MarkFile%" (
  61. @call :ColorText E0 "[WARN] 检测到当前安装的系统环境为开发人员环境,将跳过部分设置,避免影响开发日常工作"
  62. @set installPure=0
  63. )
  64. )
  65. @echo [DEBUG] installPure=%installPure%
  66. @if exist "D:\\" (
  67. @if exist "D:\\Run\\version\\vtm.exe" (
  68. @set rvc_install_path_root=D:
  69. @set sysdisk=0
  70. ) else (
  71. @set rvc_install_path_root=D:
  72. @set sysdisk=0
  73. )
  74. )
  75. @echo [DEBUG] rvc_install_path_root=%rvc_install_path_root%
  76. @echo [DEBUG] rvc_src_path_Run_dir=%rvc_src_path_Run_dir%
  77. @set rvc_install_path_rvc_dir=%rvc_install_path_root%\rvc
  78. @set rvc_install_path_rvc_res_dir=%rvc_install_path_root%\rvc\Resources
  79. @set rvc_install_path_Run_dir=%rvc_install_path_root%\Run
  80. @set rvc_install_path_hardware_dir=%rvc_install_path_Run_dir%\hardwarecfg
  81. @set rvc_install_path_versions_dir=%rvc_install_path_Run_dir%\version
  82. @echo [DEBUG] rvc_install_path_rvc_dir=%rvc_install_path_rvc_dir%
  83. @echo [DEBUG] rvc_install_path_rvc_res_dir=%rvc_install_path_rvc_res_dir%
  84. @echo [DEBUG] rvc_install_path_Run_dir=%rvc_install_path_Run_dir%
  85. @echo [DEBUG] rvc_install_path_hardware_dir=%rvc_install_path_hardware_dir%
  86. @echo [DEBUG] rvc_install_path_versions_dir=%rvc_install_path_versions_dir%
  87. @echo 【0/1】拷贝RVC目录...
  88. @if not exist "%rvc_src_path_rvc_res_dir%" (
  89. @call :ColorText 4F "[ERROR] Resources文件夹不存在,请检查安装包的合法性和完整性!!"
  90. @goto InstallError
  91. )
  92. @if not exist "%rvc_install_path_rvc_dir%" md "%rvc_install_path_rvc_dir%"
  93. @if not exist "%rvc_install_path_rvc_res_dir%" md "%rvc_install_path_rvc_res_dir%"
  94. @xcopy "%rvc_src_path_rvc_res_dir%" %rvc_install_path_rvc_res_dir% /E/Y/Q
  95. @echo 【1/1】拷贝RVC目录OK!
  96. @if not exist "%rvc_src_path_Run_dir%" (
  97. @call :ColorText 4F "[ERROR] Run版本文件夹不存在,请检查安装包的合法性和完整性!!"
  98. @goto InstallError
  99. )
  100. @if not exist "%rvc_src_path_Run_dir%\version" (
  101. @call :ColorText 4F "[ERROR] version文件夹不存在,请检查安装包的合法性和完整性!!"
  102. @goto InstallError
  103. )
  104. @if not exist "%rvc_install_path_Run_dir%" md "%rvc_install_path_Run_dir%"
  105. @echo 【1/2】拷贝终端版本,文件数量较多,部分终端拷贝时间比较长,请稍加等候......
  106. @if exist "%rvc_src_path_Run_dir%\hardwarecfg" (
  107. @if not exist "%rvc_install_path_hardware_dir%" md "%rvc_install_path_hardware_dir%"
  108. @xcopy "%rvc_src_path_Run_dir%\hardwarecfg" "%rvc_install_path_hardware_dir%" /E/Y/Q
  109. )
  110. @if not exist "%rvc_install_path_versions_dir%" md "%rvc_install_path_versions_dir%"
  111. @xcopy "%rvc_src_path_Run_dir%\version" "%rvc_install_path_versions_dir%" /E/Y/Q
  112. @echo 【2/2】拷贝终端版本OK!
  113. @echo 【2/3】设置系统桌面壁纸
  114. @set FileCount=0
  115. @set desk_path=%USERPROFILE%\Desktop
  116. @set desk_path_pub=C:\Users\Public\Desktop
  117. @if %installPure% equ 0 (
  118. @call :ColorText E0 "[WARN] 开发设备不清理桌面和设置壁纸,直接跳过"
  119. @goto doNotRunUpdatePerEtc
  120. )
  121. @echo [INFO] 清理桌面文件内容
  122. @for /d %%a in (%desk_path%\*) do (
  123. @echo [DEBUG] 桌面文件夹:%%a
  124. @rd /S /Q "%%a"
  125. )
  126. @for %%a in (%desk_path%\*) do (
  127. @echo [DEBUG] 桌面文件:%%a
  128. @del "%%a"
  129. )
  130. @for /d %%a in (%desk_path_pub%\*) do (
  131. @echo [DEBUG] 公共桌面文件夹:%%a
  132. @rd /S /Q "%%a"
  133. )
  134. @for %%a in (%desk_path_pub%\*) do (
  135. @echo [DEBUG] 公共桌面文件:%%a
  136. @del "%%a"
  137. )
  138. @echo [INFO] 清理桌面 此电脑 图标
  139. reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {20D04FE0-3AEA-1069-A2D8-08002B30309D} /t REG_DWORD /d 1 /f
  140. reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" /v {20D04FE0-3AEA-1069-A2D8-08002B30309D} /t REG_DWORD /d 1 /f
  141. @echo [INFO] 清理桌面 回收站 图标
  142. reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {645FF040-5081-101B-9F08-00AA002F954E} /t REG_DWORD /d 1 /f
  143. reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" /v {645FF040-5081-101B-9F08-00AA002F954E} /t REG_DWORD /d 1 /f
  144. @echo [INFO] 清理桌面 网络 图标
  145. reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {F02C1A0D-BE21-4350-88B0-7367FC96EF3C} /t REG_DWORD /d 1 /f
  146. reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" /v {F02C1A0D-BE21-4350-88B0-7367FC96EF3C} /t REG_DWORD /d 1 /f
  147. @echo [INFO] 清理桌面 控制面板 图标
  148. reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0} /t REG_DWORD /d 1 /f
  149. reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" /v {5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0} /t REG_DWORD /d 1 /f
  150. @echo [INFO] 清理桌面 用户的文件 图标
  151. reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {59031a47-3f72-44a7-89c5-5595fe6b30ee} /t REG_DWORD /d 1 /f
  152. reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" /v {59031a47-3f72-44a7-89c5-5595fe6b30ee} /t REG_DWORD /d 1 /f
  153. @echo [INFO] 清理桌面文件内容OK!
  154. @set backupWallPaperPath=%rvc_install_path_root%\\rvc\\Resources\\WallPaper1920.png
  155. @set WallpaperPath=%rvc_install_path_rvc_res_dir%\WallPaper1920.png
  156. @if not exist C:\Windows\Web\Wallpaper\WallPaper1920.png (
  157. @if exist "C:\Windows\Web\Wallpaper" (
  158. @if not exist "%WallpaperPath%" (
  159. @call :ColorText 4F "[ERROR] 壁纸资源文件不存在,请检查安装包的合法性和完整性!!"
  160. @goto InstallError
  161. )
  162. @copy "%WallpaperPath%" C:\Windows\Web\Wallpaper
  163. @set WallpaperPath=C:\Windows\Web\Wallpaper\WallPaper1920.png
  164. @set backupWallPaperPath=C:\\Windows\\Web\\Wallpaper\\WallPaper1920.png
  165. )
  166. ) else (
  167. @echo [DEBUG] 指定壁纸已存在系统目录
  168. @set WallpaperPath=C:\Windows\Web\Wallpaper\WallPaper1920.png
  169. @set backupWallPaperPath=C:\\Windows\\Web\\Wallpaper\\WallPaper1920.png
  170. )
  171. @echo [DEBUG] WallpaperPath=%WallpaperPath%
  172. @echo [INFO] 通过注册表设置桌面壁纸
  173. @set regWallpaperFile=%TEMP%\rvc_wallpaperset.reg
  174. reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "%WallpaperPath%" /f
  175. reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v WallpaperStyle /t REG_DWORD /d 2 /f
  176. @if %errorlevel% neq 0 (
  177. @echo [DEBUG] backupWallPaperPath=%backupWallPaperPath%
  178. @echo Windows Registry Editor Version 5.00 > %regWallpaperFile%
  179. @echo. >> %regWallpaperFile%
  180. @echo [HKEY_CURRENT_USER\Control Panel\Desktop] >> %regWallpaperFile%
  181. @echo "Wallpaper"="%backupWallPaperPath%" >> %regWallpaperFile%
  182. @echo "WallpaperStyle"=dword:00000001 >> %regWallpaperFile%
  183. regedit /s %regWallpaperFile%
  184. @del %regWallpaperFile%
  185. )
  186. @echo 【3/3】设置系统桌面壁纸OK!
  187. :doNotRunUpdatePerEtc
  188. @echo 【3/4】设置可视柜台应用程序开机自启动
  189. @echo [DEBUG] 读取注册表信息
  190. @set regFile=%TEMP%\rvc_spshellautostart.reg
  191. @set regTmpFile=%TEMP%\rvckey.txt
  192. @rem @echo [DEBUG] %regFile%
  193. @rem @echo [DEBUG] %regTmpFile%
  194. @set explorerKey=
  195. @set needSetAutoStartFlag=1
  196. @set explorerNormal=0
  197. regedit /e %regFile% "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
  198. @type %regFile% | find /I """Shell""=" > "%regTmpFile%"
  199. @for /f "usebackq delims== tokens=2" %%a in ("%regTmpFile%") do (
  200. @set explorerKey=%%~a
  201. )
  202. @del "%regFile%"
  203. @del "%regTmpFile%"
  204. @for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do call set explorerKey=%%explorerKey:%%i=%%i%%
  205. @echo [DEBUG] explorer key:%explorerKey%
  206. @if "%explorerKey%" == "explorer.exe" (
  207. @echo [INFO] 检测到未设置为开机自启动模式
  208. @set explorerNormal=1
  209. ) else if "%explorerKey%" == "d:\\run\\version\\vtm.exe" (
  210. @call :ColorText 2F "检测到已设置为VTM.exe开机自启动模式"
  211. @set needSetAutoStartFlag=0
  212. ) else if "%explorerKey%" == "wscript d:\\run\\version\\spexplorerfast.vbs" (
  213. @echo [INFO] 检测到已设置为VBS脚本开机自启动模式
  214. )
  215. @echo [DEBUG] 移除旧有的可视柜台自启动文件(如有)
  216. @if exist "%AutoStartDir%\%lnkPath%" (
  217. @echo [DEBUG] 移除历史自启动文件 %AutoStartDir%\%lnkPath%
  218. @del "%AutoStartDir%\%lnkPath%"
  219. )
  220. @if exist "%AutoStartDir2%\%lnkPath%" (
  221. @echo [DEBUG] 移除历史自启动文件 %AutoStartDir2%\%lnkPath%
  222. @del "%AutoStartDir2%\%lnkPath%"
  223. )
  224. @rem 移除旧有的可视柜台自启动快捷键(通过安装程序自动生成的)
  225. @for %%i in ("%AutoStartDir2%\招商银行可视柜台*.lnk") do (
  226. @echo [DEBUG] 移除历史自启动文件 %%i
  227. @del "%%i"
  228. )
  229. @set targetPath=%rvc_install_path_versions_dir%\vtm.exe
  230. @if %installPure% equ 1 goto setAutoStartAndDesktopIcon
  231. @call :ColorText E0 "[WARN] 开发设备不设置开机自启动,仅设置桌面图标"
  232. mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b1=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\可视柜台.lnk""):b1.TargetPath=""%targetPath%"":b1.WorkingDirectory=""%rvc_install_path_versions_dir%"":b1.Description=""招行可视柜台终端应用"":b1.Save:close")
  233. @goto DoneAutostartSet
  234. :setAutoStartAndDesktopIcon
  235. @echo [INFO] 设置应用自启动和桌面图标
  236. @rem ResourceWatcher:可视柜台.lnk
  237. @rem RVCTerminalApplication:招商银行可视柜台.lnk
  238. mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""startup"") & ""\%lnkPath%""):b.TargetPath=""%targetPath%"":b.WorkingDirectory=""%rvc_install_path_versions_dir%"":b.Description=""招行可视柜台终端应用"":b.Save:Set b1=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\可视柜台.lnk""):b1.TargetPath=""%targetPath%"":b1.WorkingDirectory=""%rvc_install_path_versions_dir%"":b1.Description=""招行可视柜台终端应用"":b1.Save:close")
  239. :DoneAutostartSet
  240. @echo 【4/4】设置可视柜台应用程序开机自启动OK!
  241. @goto End
  242. :InstallError
  243. @set ret=1
  244. :End
  245. @if "%ret%" == "1" (
  246. @call :ColorText 4F "[ERROR] 安装失败,具体失败步骤见上方描述!!"
  247. @pause
  248. @goto Done
  249. )
  250. @for /d %%a in ("%rvc_src_path_Run_dir%\version\*") do (
  251. @set RVCTerminalDirFullPath=%%a
  252. @set RVCTerminalDirName=%%~nxa
  253. @goto GetRVCTerminalDirNameDone
  254. )
  255. :GetRVCTerminalDirNameDone
  256. @set RVCCurInstallVersion=%RVCTerminalDirName%
  257. @echo [DEBUG] RVCCurInstallVersion=%RVCCurInstallVersion%
  258. @call :ColorText 2F "[INFO] ===所有安装步骤执行成功,正常退出,请双击桌面图标启动可视柜台应用进入安装配置,可视柜台应用版本号:%RVCCurInstallVersion%==="
  259. @set /a timoutsecs=5
  260. @echo [INFO] %timoutsecs%s 后自动退出该执行脚本并最小化到桌面
  261. @for /l %%a in (1, 1, %timoutsecs%) do (
  262. timeout 1 > nul
  263. @set /a lastsecs=%timoutsecs%-%%a
  264. @echo [INFO] !lastsecs!s 后自动退出该执行脚本并最小化到桌面
  265. )
  266. @echo 最小化到桌面并退出脚本流程
  267. @rem MinimizeAll ToggleDesktop
  268. mshta VBScript:Execute("Set a=CreateObject(""Shell.Application""):a.MinimizeAll:close")
  269. @rem @start %rvc_install_path_versions_dir%
  270. :Done
  271. @exit %ret%
  272. :stringLenth
  273. @set thestring=%~1
  274. @if not defined theString (
  275. @set Return=0
  276. @set %2=0
  277. @goto :eof
  278. )
  279. @set Return=0
  280. :stringLenth_continue
  281. @set /a Return+=1
  282. @set thestring=%thestring:~0,-1%
  283. @if defined thestring goto stringLenth_continue
  284. @if not "%2"=="" set %2=%Return%
  285. @goto :eof
  286. :ColorText
  287. @rem color 2F 这里的2代表背景,F代表字色
  288. @rem 0=黑、1=蓝、2=绿、3=浅绿、4=红、5=紫、6=黄、7=白、8=灰、9=淡蓝、
  289. @rem A=淡绿、B=淡浅绿、C=淡红、D=淡紫、E=淡黄、F=亮白
  290. <nul set /p ".=%DEL%" > "%~2"
  291. @findstr /v /a:%1 /R "^$" "%~2" nul
  292. @del "%~2" > nul 2>&1
  293. @echo.
  294. @goto :eof