通过vbs调用bat文件达到隐藏cmd窗口的效果

1. 创建一个如下所示的call-bat.vbs文件:

Dim cmdStr
cmdStr = WScript.Arguments(0)
 
Set WsShell = CreateObject("Wscript.Shell") 
WsShell.Run cmdStr & " /start", 0

2. 假设同一级目录下有一个test.bat 的批处理文件:

@echo off
ping -n 3600 127.0.0.1 > nul

3.打开命令行提示窗口,输入如下命令:

cscript call-bat.vbs test.bat >> test-bat.log

发表评论

邮箱地址不会被公开。 必填项已用*标注