返回列表 发帖

[问题求助] VBS如何生成批处理文件/如何将批处理代码写入到bat文件

本帖最后由 pcl_test 于 2016-8-21 14:34 编辑

tasklist|findstr "VPN代理.exe"||goto :E
:K
exit
:E
start "" "VPN代理.exe"
exit

---------------------------------------------------------------------------------------------------------------------

以上代码怎么用VBS写出保存到1.bat

用vbs生成bat文件?直接用fso,太简单了。

要生成一个bat临时文件还不如干脆直接用vbs
CreateObject("WScript.Shell").Run "cmd /c tasklist|findstr VPN代理.exe||start VPN代理.exe",0COPY
或者
if GetObject("winmgmts:").ExecQuery("Select * from Win32_Process Where Name = 'VPN代理.exe'").Count=0 then
    CreateObject("WScript.Shell").Run "VPN代理.exe"
else
    WScript.Quit
end ifCOPY

TOP

返回列表