@setlocal enabledelayedexpansion @echo off @rem 要求以管理员方式启动 bcdedit >nul if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto UACAdmin) :UACPrompt %1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&exit exit /B :UACAdmin color 0F @cls title 【可视柜台应用程序安装脚本】 for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( set "DEL=%%a" ) cd /d "%~dp0" @set /a argumentNum=0 @set ret=0 @rem 1 关机 2 重启 @set poweroffPC=0 @set /a installType=0 @set installPure=1 @for %%a in (%*) do set /a argumentNum+=1 @if %argumentNum% gtr 0 ( @echo argument count: %argumentNum% @if %argumentNum% == 1 ( @if "%1" == "uninstall" ( @set installType=4 ) else if "%1" == "pure" ( @set installType=1 ) ) ) else ( @echo no any arguments ) @echo [RVCTermianal] ========== Install Start ========== @echo 安装脚本模式: %installType% @set sysProductKey= for /f "skip=1 delims==" %%i in ('wmic path softwarelicensingservice get OA3xOriginalProductKey') do ( @set sysProductKey=%%i @goto DoneGetProductKey ) :DoneGetProductKey @echo sysProductKey=%sysProductKey% if "%sysProductKey%" == "" ( @echo [DEBUG] 操作系统未激活! ) else ( @echo [DEBUG] 操作系统已激活。 ) @set ROOT=%cd% @set rvc_src_path_rvc_dir=%ROOT%\rvc @set rvc_src_path_Run_dir=%ROOT%\Run @set rvc_src_path_rvc_res_dir=%rvc_src_path_rvc_dir%\Resources @set rvc_install_path_root=%HOMEDRIVE%: @set sysdisk=1 @set lnkPath=spexplorerauto.lnk @set AutoStartDir=C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup @set AutoStartDir2=C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp @set VS2019MarkFile=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe tasklist /nh | find /i "spshell.exe" @if errorlevel 1 ( @echo [INFO] 可视柜台进程不存在,跳过进程清理 ) else ( @echo [INFO] 检测到可视柜台进程存在,开始清理可视柜台相关进程…… TASKKILL /F /IM spshell.exe TASKKILL /F /IM guardian.exe TASKKILL /F /IM cefclient.exe @for /f "tokens=1,2 delims= " %%a in ('tasklist /m ^| findstr "sphost.exe"') do ( @echo name=%%a, PID = %%b, and will kill it. TASKKILL /F /PID %%a ) ) @rem 如果是非生产环境并且且是开发者的电脑在安装版本,那么部分公共的设置不生效,例如壁纸,开机自启动 @if %installType% equ 0 ( @if exist "%VS2019MarkFile%" ( @call :ColorText E0 "[WARN] 检测到当前安装的系统环境为开发人员环境,将跳过部分设置,避免影响开发日常工作" @set installPure=0 ) ) @echo [DEBUG] installPure=%installPure% @if exist "D:\\" ( @if exist "D:\\Run\\version\\vtm.exe" ( @set rvc_install_path_root=D: @set sysdisk=0 ) else ( @set rvc_install_path_root=D: @set sysdisk=0 ) ) @echo [DEBUG] rvc_install_path_root=%rvc_install_path_root% @echo [DEBUG] rvc_src_path_Run_dir=%rvc_src_path_Run_dir% @set rvc_install_path_rvc_dir=%rvc_install_path_root%\rvc @set rvc_install_path_rvc_res_dir=%rvc_install_path_root%\rvc\Resources @set rvc_install_path_Run_dir=%rvc_install_path_root%\Run @set rvc_install_path_hardware_dir=%rvc_install_path_Run_dir%\hardwarecfg @set rvc_install_path_versions_dir=%rvc_install_path_Run_dir%\version @echo [DEBUG] rvc_install_path_rvc_dir=%rvc_install_path_rvc_dir% @echo [DEBUG] rvc_install_path_rvc_res_dir=%rvc_install_path_rvc_res_dir% @echo [DEBUG] rvc_install_path_Run_dir=%rvc_install_path_Run_dir% @echo [DEBUG] rvc_install_path_hardware_dir=%rvc_install_path_hardware_dir% @echo [DEBUG] rvc_install_path_versions_dir=%rvc_install_path_versions_dir% @set RVCTerminalDirName= @set RVCTerminalDirFullPath= @set RVCCurInstallVersion= @for /d %%a in ("%rvc_src_path_Run_dir%\version\*") do ( @set RVCTerminalDirFullPath=%%a @set RVCTerminalDirName=%%~nxa @goto GetRVCTerminalDirNameDone ) :GetRVCTerminalDirNameDone @set RVCCurInstallVersion=%RVCTerminalDirName% @echo [DEBUG] RVCCurInstallVersion=%RVCCurInstallVersion% @if not exist "%rvc_install_path_rvc_dir%" md "%rvc_install_path_rvc_dir%" @if not exist "%rvc_install_path_rvc_res_dir%" md "%rvc_install_path_rvc_res_dir%" @if not exist "%rvc_install_path_Run_dir%" md "%rvc_install_path_Run_dir%" @if not exist "%rvc_install_path_hardware_dir%" md "%rvc_install_path_hardware_dir%" @if not exist "%rvc_install_path_versions_dir%" md "%rvc_install_path_versions_dir%" @echo 【0/1】拷贝RVC目录... @xcopy "%rvc_src_path_rvc_dir%" %rvc_install_path_rvc_dir% /E/Y/Q @echo 【1/1】拷贝RVC目录OK! @echo 【1/2】拷贝终端版本,文件数量较多,部分终端拷贝时间比较长,请稍加等候...... @if exist "%rvc_src_path_Run_dir%\hardwarecfg" ( xcopy "%rvc_src_path_Run_dir%\hardwarecfg" "%rvc_install_path_hardware_dir%" /E/Y/Q ) @xcopy "%rvc_src_path_Run_dir%\version" "%rvc_install_path_versions_dir%" /E/Y/Q @echo 【2/2】拷贝终端版本OK! @echo 【2/3】设置系统桌面壁纸 @set FileCount=0 @set desk_path=%USERPROFILE%\Desktop @set desk_path_pub=C:\Users\Public\Desktop @echo [DEBUG] desk_path=%desk_path% @if %installPure% equ 0 ( @call :ColorText E0 "[WARN] 开发设备不清理桌面和设置壁纸,直接跳过" @goto doNotRunUpdatePerEtc ) @echo [INFO] 清理桌面文件内容 @for /d %%a in (%desk_path%\*) do ( @echo [DEBUG] %%a @rd /S /Q "%%a" ) @for %%a in (%desk_path%\*) do ( @echo [DEBUG] %%a @del "%%a" ) @for /d %%a in (%desk_path_pub%\*) do ( @echo [DEBUG] %%a @rd /S /Q "%%a" ) @for %%a in (%desk_path_pub%\*) do ( @echo [DEBUG] %%a @del "%%a" ) @echo [INFO] 清理桌面 此电脑 图标 reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {20D04FE0-3AEA-1069-A2D8-08002B30309D} /t REG_DWORD /d 1 /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" /v {20D04FE0-3AEA-1069-A2D8-08002B30309D} /t REG_DWORD /d 1 /f @echo [INFO] 清理桌面 回收站 图标 reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {645FF040-5081-101B-9F08-00AA002F954E} /t REG_DWORD /d 1 /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" /v {645FF040-5081-101B-9F08-00AA002F954E} /t REG_DWORD /d 1 /f @echo [INFO] 清理桌面 网络 图标 reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {F02C1A0D-BE21-4350-88B0-7367FC96EF3C} /t REG_DWORD /d 1 /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" /v {F02C1A0D-BE21-4350-88B0-7367FC96EF3C} /t REG_DWORD /d 1 /f @echo [INFO] 清理桌面 控制面板 图标 reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0} /t REG_DWORD /d 1 /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" /v {5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0} /t REG_DWORD /d 1 /f @echo [INFO] 清理桌面 用户的文件 图标 reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {59031a47-3f72-44a7-89c5-5595fe6b30ee} /t REG_DWORD /d 1 /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" /v {59031a47-3f72-44a7-89c5-5595fe6b30ee} /t REG_DWORD /d 1 /f @echo [INFO] 清理桌面文件内容OK! @set backupWallPaperPath=%rvc_install_path_root%\\rvc\\Resources\\WallPaper1920.png @set WallpaperPath=%rvc_install_path_rvc_res_dir%\WallPaper1920.png @if not exist C:\Windows\Web\Wallpaper\WallPaper1920.png ( @if exist "C:\Windows\Web\Wallpaper" ( @if not exist "%WallpaperPath%" ( @call :ColorText 4F "[ERROR] 壁纸资源文件不存在,请检查版本的合法性和完整性!!" @goto InstallError ) @copy "%WallpaperPath%" C:\Windows\Web\Wallpaper @set WallpaperPath=C:\Windows\Web\Wallpaper\WallPaper1920.png @set backupWallPaperPath=C:\\Windows\\Web\\Wallpaper\\WallPaper1920.png ) ) else ( @echo [DEBUG] 指定壁纸已存在系统目录 @set WallpaperPath=C:\Windows\Web\Wallpaper\WallPaper1920.png @set backupWallPaperPath=C:\\Windows\\Web\\Wallpaper\\WallPaper1920.png ) @echo [DEBUG] WallpaperPath=%WallpaperPath% @echo [INFO] 通过注册表设置桌面壁纸 @set regWallpaperFile=%TEMP%\rvc_wallpaperset.reg reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "%WallpaperPath%" /f reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v WallpaperStyle /t REG_DWORD /d 2 /f @if %errorlevel% neq 0 ( @echo [DEBUG] backupWallPaperPath=%backupWallPaperPath% @echo Windows Registry Editor Version 5.00 > %regWallpaperFile% @echo. >> %regWallpaperFile% @echo [HKEY_CURRENT_USER\Control Panel\Desktop] >> %regWallpaperFile% @echo "Wallpaper"="%backupWallPaperPath%" >> %regWallpaperFile% @echo "WallpaperStyle"=dword:00000001 >> %regWallpaperFile% regedit /s %regWallpaperFile% @del %regWallpaperFile% ) @call :ColorText E0 "[WARN] 通过注册表设置桌面壁纸OK!(部分机器需要重启后才生效,请注意观察)" @echo 【3/3】设置系统桌面壁纸OK! :doNotRunUpdatePerEtc @echo 【3/4】设置可视柜台应用程序开机自启动 @echo [DEBUG] 读取注册表信息 @set regFile=%TEMP%\rvc_spshellautostart.reg @set regTmpFile=%cd%\rvckey.txt @set explorerKey= @set needSetAutoStartFlag=1 @set explorerNormal=0 regedit /e %regFile% "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" @type %regFile% | find /I """Shell""=" > "%regTmpFile%" @for /f "usebackq delims== tokens=2" %%a in ("%regTmpFile%") do ( @set explorerKey=%%~a ) @del %regFile% @del "%regTmpFile%" @echo [DEBUG] original explorer key:%explorerKey% @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%% @echo [DEBUG] explorer key:%explorerKey% @if "%explorerKey%" == "explorer.exe" ( @echo [DEBUG] 检测到未设置为开机自启动模式 @set explorerNormal=1 ) else if "%explorerKey%" == "d:\\run\\version\\vtm.exe" ( @call :ColorText 2F "检测到已设置为VTM.exe开机自启动模式" @set needSetAutoStartFlag=0 ) else if "%explorerKey%" == "wscript d:\\run\\version\\spexplorerfast.vbs" ( @echo [DEBUG] 检测到已设置为VBS脚本开机自启动模式 ) @if %explorerNormal% neq 1 ( @echo [DEBUG] 取消可视柜台应用程序开机自启动(同时恢复桌面) @echo [DEBUG] 临时存储取消开机自启动的注册表脚本 @echo Windows Registry Editor Version 5.00 > %regFile% @echo. >> %regFile% @echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon] >> %regFile% @echo "Shell1"="d:\\run\\version\\vtm.exe" >> %regFile% @echo "Shell"="explorer.exe" >> %regFile% @echo [DEBUG] 更新注册表! regedit /s %regFile% @del %regFile% ) @echo [DEBUG] 移除旧有的可视柜台自启动文件 @echo [DEBUG] AutoStartDir=%AutoStartDir% @echo [DEBUG] AutoStartDir2=%AutoStartDir2% @if exist "%AutoStartDir%\%lnkPath%" ( @echo [DEBUG] 移除自启动文件1 @del "%AutoStartDir%\%lnkPath%" ) @if exist "%AutoStartDir2%\%lnkPath%" ( @echo [DEBUG] 移除自启动文件2 @del "%AutoStartDir2%\%lnkPath%" ) @rem 移除旧有的可视柜台自启动快捷键(通过安装程序自动生成的) @for %%i in ("%AutoStartDir2%\招商银行可视柜台*.lnk") do ( @echo [DEBUG] %%i @del "%%i" ) @set targetPath=%rvc_install_path_versions_dir%\vtm.exe @if %installPure% equ 1 goto setAutoStartAndDesktopIcon @call :ColorText E0 "[WARN] 开发设备不设置开机自启动,仅设置桌面图标" 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") @goto DoneAutostartSet :setAutoStartAndDesktopIcon @echo [INFO] 设置应用自启动和桌面图标 @rem ResourceWatcher:可视柜台.lnk @rem RVCTerminalApplication:招商银行可视柜台.lnk 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") :DoneAutostartSet @echo 【4/4】设置可视柜台应用程序开机自启动OK! @goto End :InstallError @set ret=1 :End @if "%ret%" == "1" ( @call :ColorText 4F "[ERROR] 安装失败,具体失败步骤见上方描述!!" @pause @goto Done ) @call :ColorText 2F "[INFO] ===所有安装步骤执行成功,正常退出,请双击桌面图标启动可视柜台应用进入安装配置,可视柜台应用版本号:%RVCCurInstallVersion%===" @set /a timoutsecs=5 @echo [INFO] %timoutsecs%s 后自动退出该执行脚本并最小化到桌面 @for /l %%a in (1, 1, %timoutsecs%) do ( timeout 1 > nul @set /a lastsecs=%timoutsecs%-%%a @echo [INFO] !lastsecs!s 后自动退出该执行脚本并最小化到桌面 ) @echo 最小化到桌面并退出脚本流程 @rem MinimizeAll ToggleDesktop mshta VBScript:Execute("Set a=CreateObject(""Shell.Application""):a.MinimizeAll:close") @rem @start %rvc_install_path_versions_dir% :Done @exit %ret% :stringLenth @set thestring=%~1 @if not defined theString ( @set Return=0 @set %2=0 @goto :eof ) @set Return=0 :stringLenth_continue @set /a Return+=1 @set thestring=%thestring:~0,-1% @if defined thestring goto stringLenth_continue @if not "%2"=="" set %2=%Return% @goto :eof :ColorText @rem color 2F 这里的2代表背景,F代表字色 @rem 0=黑、1=蓝、2=绿、3=浅绿、4=红、5=紫、6=黄、7=白、8=灰、9=淡蓝、 @rem A=淡绿、B=淡浅绿、C=淡红、D=淡紫、E=淡黄、F=亮白 "%~2" @findstr /v /a:%1 /R "^$" "%~2" nul @del "%~2" > nul 2>&1 @echo. @goto :eof