简体   繁体   English

Windows任务计划程序设置为“如果已登录或未运行”,则不运行VBScript

[英]Windows Task Scheduler not running VBScript when set to “Run if logged on or not”

I'm trying to run a .vbs file as a scheduled task through Windows Task Scheduler. 我正在尝试通过Windows任务计划程序将.vbs文件作为计划任务运行。 Under the 'General' tab, when I select "Run only when user is logged on", the script executes as expected. 在“常规”选项卡下,当我选择“仅在用户登录时运行”时,脚本将按预期执行。

However, when I select "Run whether user is logged on or not", and enter the appropriate credentials, the task runs at the scheduled time, but the script does not actually run. 但是,当我选择“运行用户是否登录”并输入相应的凭据时,任务将在计划的时间运行,但脚本实际上并未运行。 I've already tried running the script under wscript.exe as well as cscript.exe, but no luck with either. 我已经尝试在wscript.exe下运行脚本以及cscript.exe,但两者都没有运气。

EDIT: Even if I am logged in when the task begins, the script will still not run under the "logged in or out" setting. 编辑:即使我在任务开始登录,脚本仍然无法在“登录或退出”设置下运行。

Additional info: The purpose of this scheduled task is to run before I arrive at work. 附加信息:此计划任务的目的是在我到达工作岗位之前运行。 I've already configured my BIOS to startup at a predetermined time (06:00), and set the Task Scheduler to run at 06:27. 我已经将BIOS配置为在预定时间(06:00)启动,并将任务计划程序设置为在06:27运行。 I've successfully tested the BIOS startup, as well as the script itself (including using the Task Scheduler to run it). 我已经成功测试了BIOS启动以及脚本本身(包括使用Task Scheduler来运行它)。 Therefore, the only weak link I can find is the option to "Run whether the user is logged on or not". 因此,我能找到的唯一弱链接是“运行用户是否登录”选项。

I'm running Windows 7 Enterprise. 我正在运行Windows 7 Enterprise。

Any help would be appreciated! 任何帮助,将不胜感激!

This is because normally it would run the script using the shell handler, which by default is wscript.exe . 这是因为通常它会使用shell处理程序运行脚本,该处理程序默认为wscript.exe When there's no desktop environment (because no-one is logged-in) it would fail and abort script execution (or rather, not run the script in the first place). 如果没有桌面环境(因为没有人登录),它将失败并中止脚本执行(或者更确切地说,不首先运行脚本)。

To fix this, instead of running the .vbs file directly, change it to run cscript.exe (the command-line script runtime program) with the script's filename passed as the first argument. 要解决此问题,请将其更改为运行cscript.exe (命令行脚本运行时程序),而不是直接运行.vbs文件,并将脚本的文件名作为第一个参数传递。 Also be sure to ensure you don't have any InputBox or MessageBox calls (instead use WScript.Echo to return messages to the user: wscript displays message-boxes, but cscript will write it to the console. 另外一定要确保没有任何InputBoxMessageBox调用(而是使用WScript.Echo将消息返回给用户: wscript显示消息框,但cscript会将其写入控制台。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows 任务计划程序不运行 VBScript - Windows Task Scheduler Doesn't Run VBScript VBScript 不会从从 Windows 任务计划程序运行的 Powershell 脚本中运行 - VBScript will not run from Powershell script that runs from Windows Task Scheduler Windows Task Scheduler运行批处理文件,该批处理文件调用运行宏的vbscript - Windows Task Scheduler to Run batch file that calls vbscript that runs a macro vbscript中的.GetAbsolutePathName(“。”)在由任务调度程序运行时未获得正确的路径 - .GetAbsolutePathName(“.”) in vbscript does not get correct path when run by task scheduler 从任务计划程序运行时如何使用VBScript关闭Outlook - How to close Outlook with VBScript when run from Task Scheduler 由Task Scheduler运行时,VBScript和批处理文件失败 - VBScript and batch file fails when run by Task Scheduler 使用Windows Scheduler运行时,VBScript花费的时间明显更长 - VBScript takes significantly longer when run using Windows Scheduler 任务计划程序正在运行,但未完成或无法正常工作VBscript - Task Scheduler running but not finishing or working properly VBscript VBScript任务计划程序不起作用? - VBScript Task scheduler not working? 在计算机锁定时通过任务计划程序运行VBScript - Running VBScript through task scheduler while computer is locked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM