问题描述
我正在尝试使用 Windows 任务计划程序自动执行 VBScript.但是,我尝试使用 cscript.exe
+ "C:...script.vbs"
但它没有运行.我还尝试在 CMD 中直接运行相同的命令 (cscript.exe "C:...script.vbs"
) 并且它起作用了.
I am trying to automate a VBScript by using Windows Task Scheduler. However, I tried to use cscript.exe
+ "C:...script.vbs"
but it didn't run. I also tried to directly run the same command in CMD (cscript.exe "C:...script.vbs"
) and it worked.
可能是什么问题?
我只是尝试将设置切换为 仅在用户登录时运行"
从 运行用户是否登录"
并且它起作用了.我想知道是否有办法让我的任务即使在用户注销时也能运行.
I just tried to switch the setting to "Run only when user is logged on"
from "Run whether user is logged on or not"
and it worked. I am wondering if there is a way to make my task scheduled run even when the user is logged off.
推荐答案
经过数小时的研究,Blake Morrison(来自 Microsoft)的博客之一出现了;它提到
After hours of research, one of Blake Morrison (from Microsoft)'s blogs came up; it mentioned that
如果运行 .vbs/.ps1 脚本,请尝试从 .cmd/.bat 脚本启动它
那个博客还解释了很多使用 Task Scheduler 的规则/技巧.
That blog also explains a lot of rules/tips when using Task Scheduler.
因此,请创建一个调用您的 VBScript 的 .cmd/.bat 文件.例如:cscript.exe YourScript.vbs
将在您的 .cmd/.bat 脚本中.
So please create a .cmd/.bat file that calls for your VBScript. For example: cscript.exe YourScript.vbs
would be in your .cmd/.bat script.
这篇关于Windows 任务计划程序不运行 VBScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!