复制代码
- @echo off
- cls
- ::定义bat外观
- title 『自动复制ocx控件文件到系统并注册』
- MODE con: COLS=80 LINES=25
- color 5E
- echo ___________________________________________________________________________
- echo.
- echo 请稍等,正在复制所需的控件到系统并注册中...........
- echo ___________________________________________________________________________
- %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
- cd /d %~dp0
- ver | find "4.0" > NUL && goto win95
- ver | find "4.1" > NUL && goto win98
- ver | find "4.9" > NUL && goto winMe
- ver | find "5.0" > NUL && goto win2000
- ver | find "5.1" > NUL && goto winxp
- ver | find "5.2" > NUL && goto win2003
- ver | find "6.0" > NUL && goto win2008
- ver | find "6.1" > NUL && goto win7
- ver | find "6.2" > NUL && goto win8
- ver | find "6.3" > NUL && goto win8.1
- ver | find "10.0" > NUL && goto win10
- :win95
- @echo 当前系统是:Windows 95
- @echo ----------------------------------------
- goto winxp_dn
- :win98
- @echo 当前系统是:Windows 98
- @echo ----------------------------------------
- goto winxp_dn
- :winMe
- @echo 当前系统是:Windows Me
- @echo ----------------------------------------
- goto winxp_dn
- :win2000
- @echo 当前系统是:Windows 2000
- @echo ----------------------------------------
- goto winxp_dn
- :winxp
- @echo 当前系统是:Windows XP
- @echo ----------------------------------------
- goto winxp_dn
- :win2003
- @echo 当前系统是:Windows Server 2003
- @echo ----------------------------------------
- goto winxp_dn
- :win2008
- @echo 当前系统是:Windows Vista
- @echo ----------------------------------------
- goto winxp_up
- :win7
- @echo 当前系统是:Windows 7
- @echo ----------------------------------------
- goto winxp_up
- :win8
- @echo 当前系统是:Windows 8
- @echo ----------------------------------------
- goto winxp_up
- :win8.1
- @echo 当前系统是:Windows 8.1
- @echo ----------------------------------------
- goto winxp_up
- :win10
- @echo 当前系统是:Windows 10
- @echo ----------------------------------------
- goto winxp_up
- :winxp_dn
- @echo ----------------------------------------
- @echo 正在复制OCX控件文件到系统目录并注册............
- copy /y ".\ocx\*.OCX" "%windir%\system32"
- @echo 复制完成.................................
- @echo .........................................
- @echo 注册OCX文件中............................
- %windir%\system32\regsvr32.exe %windir%\system32\MSCOMCT2.OCX /S
- %windir%\system32\regsvr32.exe %windir%\system32\MSCOMCTL.OCX /S
- @echo 注册完成.................................
- @echo .........................................
- @echo .........................................
- goto end
- :win7_up
- @echo 当前系统是:win7
- @echo ----------------------------------------
- @echo 正在复制OCX控件文件到系统目录并注册............
- if %PROCESSOR_ARCHITECTURE%==x86 goto x32
- if not %PROCESSOR_ARCHITECTURE%==x86 goto x64
- goto end
- :x64
- copy /y ".\ocx\*.OCX" "%windir%\SysWOW64"
- @echo 复制完成.................................
- @echo .........................................
- @echo 注册OCX文件中............................
- %windir%\SysWOW64\regsvr32.exe %windir%\SysWOW64\MSCOMCT2.OCX /S
- %windir%\SysWOW64\regsvr32.exe %windir%\SysWOW64\MSCOMCTL.OCX /S
- @echo 注册完成.................................
- @echo .........................................
- @echo .........................................
- goto end
- :x32
- copy /y ".\ocx\*.OCX" "%windir%\system32"
- @echo 复制完成.................................
- @echo .........................................
- @echo 注册OCX文件中............................
- %windir%\system32\regsvr32.exe %windir%\system32\MSCOMCT2.OCX /S
- %windir%\system32\regsvr32.exe %windir%\system32\MSCOMCTL.OCX /S
- @echo 注册完成.................................
- @echo .........................................
- @echo .........................................
- goto end
- @echo 获取不到当前操作系统的版本,请联系技术员处理!
- @echo --------------------------------------------------
- goto end
- :end
- pause
这一行决定了该批处理以后台运行,当然就是一闪而过了复制代码
- %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
这一行命令会让该脚本以不显示窗口的模式去运行复制代码
- %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
这个代码是隐藏打开窗口后退出复制代码
- %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
欢迎光临 批处理之家 (http://www.bathome.net/) | Powered by Discuz! 7.2 |