转载自
大多数时候,使用批处理执行一些任务。但是批处理的黑色命令窗口会一直存在很烦人。
可以通过两种方式,隐藏bat脚本。
方法1:
直接在 bat 文件最前边加上以下内容:
@echo off
if ”%1” == “h” goto begin
mshta vbscript:createobject(“wscript.shell”).run(“%~nx0 h”,0)(window.close)&&exit
:begin
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
:begin
举例:
- @echo off
- if ”%1” == “h” goto begin
- mshta vbscript:createobject(”wscript.shell”).run(“%~nx0 h”,0)(window.close)&&exit
- :begin
- @echo off
- if ”%1” == “h” goto begin
- mshta vbscript:createobject(”wscript.shell”).run(“%~nx0 h”,0)(window.close)&&exit
- :begin
- e:
- cd E:\guokySVN\资料\技术\6. ETL\02.kettle\安装包\pdi-ce-4.0.0-stable\data-integration
- Kitchen.bat /file E:\KETTLE_TEST\TEST5\mysqljob1.kjb /level:Basic>>E:\KETTLE_TEST\TEST5\mysqljob1.log
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
:begin
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
:begin
e:
cd E:\guokySVN\资料\技术\6. ETL\02.kettle\安装包\pdi-ce-4.0.0-stable\data-integration
Kitchen.bat /file E:\KETTLE_TEST\TEST5\mysqljob1.kjb /level:Basic>>E:\KETTLE_TEST\TEST5\mysqljob1.log
新建一个记事本,里面输入:
- CreateObject(“WScript.Shell”).Run “cmd /c D:/test.bat”,0
CreateObject("WScript.Shell").Run "cmd /c D:/test.bat",0
其中 D:/test.bat 是 bat 文件的绝对路径
将此新建的记事本保存为 vbs 格式文件。
以后执行这个 vbs 文件即可。