Mis*_*hko 6 batch scheduled-tasks windows-xp
我有一个批处理文件,它使用schtasks
如下方式创建计划任务:
schtasks /create /tn my_task_name
/tr "...\my_path\my_task.bat"
/sc daily
/st 10:00:00
/s \\my_computer_name
/u my_username
/p my_password
Run Code Online (Sandbox Code Playgroud)
它工作正常,除了my_task.bat
执行时 - 打开一个新的命令行窗口(并在执行后关闭)。
我想避免打开这个新窗口(即在后台以安静模式运行任务)。
我想用
start /b ...\my_path\my_task.bat
Run Code Online (Sandbox Code Playgroud)
但我不知道怎么做,因为我必须start
从批处理文件中调用,所以我需要在它前面加上cmd /c
,这又会导致新窗口打开。
我怎么能解决这个问题?
最后我用这段代码解决了这个问题:
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "...\my_task.bat" & Chr(34), 0
Set WshShell = Nothing
Run Code Online (Sandbox Code Playgroud)
将其保存并按上述run_my_task.vbs
安排。run_my_task.vbs
schtasks