Win下批处理后台运行和关闭

启动脚本 run.vbs


Dim RunKcptun
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
'获取文件路径
currentPath = fso.GetFile(Wscript.ScriptFullName).ParentFolder.Path & "\"
'软件start运行参数
exeConfig = "start \\\\"小白量化-Coinex刷单机器人QQ:278614819\\\\" python main.py"
'软件stop运行参数
exeStopConfig = "taskkill /f /im server_windows_amd64.exe"
'日志文件
logFile = "log.log"
'拼接命令行
cmdLine = "cmd /c " & currentPath & exeConfig  & " > " & currentPath & logFile & " 2>&1"

Do While True
'stop软件
WshShell.Run exeStopConfig, 0, False
'等待1秒
WScript.Sleep 1000

'启动软件
WshShell.Run cmdLine, 0, False
'等待1秒
WScript.Sleep 1000

'打印运行命令 调试用
'Wscript.echo cmdLine
'等待1小时
WScript.Sleep 3600000
Loop

'打印运行命令
'Wscript.echo cmdLine

Set WshShell = Nothing
Set fso = Nothing
'退出脚本
WScript.quit

关闭脚本 stopvbs.cmd

cmd.exe /C taskkill.exe /F /IM "wscript.exe" & taskkill.exe /F /IM "cscript.exe"


485
Sign in to leave a comment.
No Leanote account? Sign up now.
0 comments