找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 22659|回复: 6

[其他] 求助,bat运行一闪需过

[复制链接]
发表于 2021-4-22 09:28:21 | 显示全部楼层 |阅读模式
如题,bat如下:
  1. @echo off
  2. cls
  3. ::定义bat外观
  4. title  『自动复制ocx控件文件到系统并注册』
  5. MODE con: COLS=80 LINES=25
  6. color 5E

  7. echo ___________________________________________________________________________
  8. echo.
  9. echo           请稍等,正在复制所需的控件到系统并注册中...........
  10. echo ___________________________________________________________________________

  11. %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit

  12. cd /d %~dp0

  13. ver | find "4.0" > NUL &&  goto win95
  14. ver | find "4.1" > NUL &&  goto win98
  15. ver | find "4.9" > NUL &&  goto winMe
  16. ver | find "5.0" > NUL &&  goto win2000
  17. ver | find "5.1" > NUL &&  goto winxp
  18. ver | find "5.2" > NUL &&  goto win2003
  19. ver | find "6.0" > NUL &&  goto win2008
  20. ver | find "6.1" > NUL &&  goto win7
  21. ver | find "6.2" > NUL &&  goto win8
  22. ver | find "6.3" > NUL &&  goto win8.1
  23. ver | find "10.0" > NUL &&  goto win10

  24. :win95
  25. @echo           当前系统是:Windows 95  
  26. @echo ----------------------------------------
  27. goto winxp_dn

  28. :win98
  29. @echo           当前系统是:Windows 98  
  30. @echo ----------------------------------------
  31. goto winxp_dn

  32. :winMe
  33. @echo           当前系统是:Windows Me  
  34. @echo ----------------------------------------
  35. goto winxp_dn

  36. :win2000
  37. @echo           当前系统是:Windows 2000  
  38. @echo ----------------------------------------
  39. goto winxp_dn

  40. :winxp
  41. @echo           当前系统是:Windows XP  
  42. @echo ----------------------------------------
  43. goto winxp_dn

  44. :win2003
  45. @echo       当前系统是:Windows Server 2003
  46. @echo ----------------------------------------
  47. goto winxp_dn

  48. :win2008
  49. @echo         当前系统是:Windows Vista
  50. @echo ----------------------------------------
  51. goto winxp_up

  52. :win7
  53. @echo         当前系统是:Windows 7
  54. @echo ----------------------------------------
  55. goto winxp_up

  56. :win8
  57. @echo         当前系统是:Windows 8
  58. @echo ----------------------------------------
  59. goto winxp_up

  60. :win8.1
  61. @echo         当前系统是:Windows 8.1
  62. @echo ----------------------------------------
  63. goto winxp_up

  64. :win10
  65. @echo         当前系统是:Windows 10
  66. @echo ----------------------------------------
  67. goto winxp_up

  68. :winxp_dn
  69. @echo ----------------------------------------
  70. @echo 正在复制OCX控件文件到系统目录并注册............
  71. copy /y ".\ocx\*.OCX" "%windir%\system32"
  72. @echo 复制完成.................................
  73. @echo .........................................
  74. @echo 注册OCX文件中............................
  75. %windir%\system32\regsvr32.exe %windir%\system32\MSCOMCT2.OCX /S
  76. %windir%\system32\regsvr32.exe %windir%\system32\MSCOMCTL.OCX /S
  77. @echo 注册完成.................................
  78. @echo .........................................
  79. @echo .........................................
  80. goto end  

  81. :win7_up  
  82. @echo           当前系统是:win7  
  83. @echo ----------------------------------------
  84. @echo 正在复制OCX控件文件到系统目录并注册............
  85. if %PROCESSOR_ARCHITECTURE%==x86 goto x32
  86. if not %PROCESSOR_ARCHITECTURE%==x86 goto x64
  87. goto end  

  88. :x64
  89. copy /y ".\ocx\*.OCX" "%windir%\SysWOW64"
  90. @echo 复制完成.................................
  91. @echo .........................................
  92. @echo 注册OCX文件中............................
  93. %windir%\SysWOW64\regsvr32.exe %windir%\SysWOW64\MSCOMCT2.OCX /S
  94. %windir%\SysWOW64\regsvr32.exe %windir%\SysWOW64\MSCOMCTL.OCX /S
  95. @echo 注册完成.................................
  96. @echo .........................................
  97. @echo .........................................
  98. goto end

  99. :x32
  100. copy /y ".\ocx\*.OCX" "%windir%\system32"
  101. @echo 复制完成.................................
  102. @echo .........................................
  103. @echo 注册OCX文件中............................
  104. %windir%\system32\regsvr32.exe %windir%\system32\MSCOMCT2.OCX /S
  105. %windir%\system32\regsvr32.exe %windir%\system32\MSCOMCTL.OCX /S
  106. @echo 注册完成.................................
  107. @echo .........................................
  108. @echo .........................................
  109. goto end

  110. @echo    获取不到当前操作系统的版本,请联系技术员处理!
  111. @echo --------------------------------------------------
  112. goto end

  113. :end  
  114. pause
复制代码
 楼主| 发表于 2021-4-22 13:26:43 | 显示全部楼层
没有大佬帮忙看一下吗?
发表于 2021-4-22 14:44:56 | 显示全部楼层

  1. %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
复制代码
这一行决定了该批处理以后台运行,当然就是一闪而过了
发表于 2021-4-22 14:55:10 | 显示全部楼层
  1. %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
复制代码
这一行命令会让该脚本以不显示窗口的模式去运行

删除掉即可
发表于 2021-4-22 21:08:17 | 显示全部楼层
脚本中那么多 goto winxp_up,但 winxp_up 标签在哪里?
应该跟 mshta 那一行没有关系,那一行是获取管理员权限的,正常窗口显示(而非隐藏窗口)。
https://docs.microsoft.com/en-us ... /shell-shellexecute
 楼主| 发表于 2021-4-22 22:44:10 | 显示全部楼层
回复 5# WHY


    谢谢!标签弄错了
发表于 2021-4-24 09:58:05 | 显示全部楼层
  1. %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
复制代码
这个代码是隐藏打开窗口后退出
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-20 16:45 , Processed in 0.019674 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表