隱藏cmd視窗(.bat .vbs)
阿新 • • 發佈:2019-01-22
轉載自
大多數時候,使用批處理執行一些任務。但是批處理的黑色命令視窗會一直存在很煩人。
可以通過兩種方式,隱藏bat指令碼。
方法1:
直接在 bat 檔案最前邊加上以下內容:
[plain] view plain copy print?[plain] view plain copy print?- @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
舉例: [vb] view plain copy print?
- @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
方法2:
新建一個記事本,裡面輸入:
- 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 檔案即可。