如何使用 Messagebox 在 Windows 7 任务调度程序中启动 VBS 脚本? [英] How to start a VBS-script in Windows 7 task scheduler with Messagebox?

查看:68
本文介绍了如何使用 Messagebox 在 Windows 7 任务调度程序中启动 VBS 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Win7 x64 Professional,并尝试使用 Windows 任务调度程序运行 VBS 脚本.我的问题是,该脚本的行为与直接启动的脚本完全不同,即使我以高权限启动它并使用相同的用户.

I am using Win7 x64 Professional, and try to run a VBS script using the Windows task scheduler. My problem is, that the script behaves totally different than a script started directly, even if I start it with high privilieges, and using the same user.

我注意到的一件事是,例如无法在屏幕上输出任何消息框.

One thing that I have noticed is for example that it is not possible to output any messagebox on screen.

在 Windows XP 下,我记得有个选项叫允许与桌面交互",解决了很多这些问题,但我在 Win7 上找不到这些选项.

Under Windows XP, I remember there was an option called "allow interaction with desktop" that fixed a lot of these problems, but I cannot find these options on Win7.

我还尝试运行 Wscript.exe,并将脚本文件作为命令行选项传递,但这导致脚本根本没有启动,即使任务调度程序说它已正确启动.

I have also tried to run Wscript.exe, and pass the scriptfile as a commandlineoption, but this results in the script not being started at all, even though task scheduler says it was started correctly.

您能否解释一下在 Win7 中启动 VBS 的最佳方式是什么,以便与直接在资源管理器中启动的脚本具有相同的行为?

Can you please explain what is the best way to start a VBS in Win7 in order to have the same behaviour as the script would have if it was started directly in explorer?

推荐答案

你应该使用 CScript.exe 而不是 WScript.exe 以便像 WScript 这样的命令.Echo 将输出到控制台而不是对话框.正如您所指出的,计划任务应避免使用 MessageBox 或任何可能导致脚本阻塞的 UI 元素.

You should use CScript.exe over WScript.exe so that commands like WScript.Echo will be output to console instead of Dialog Box. As you point out, the scheduled task should avoid MessageBox or any UI elements that could cause your script to block.

我建议按如下方式安排您的脚本:

I recommend scheduling your script as follows:

C:\Windows\System32\CScript.exe //Nologo //B X:\PathToYourScript\YourScript.vbs

我为您选择的选项是防止徽标显示"和批处理模式".通过在命令提示符下运行 CScript/? 来查阅在线帮助.

The options I choose for you are "Prevent logo display" and "Batch mode". Consult your online help by running CScript /? on a Command Prompt.

这篇关于如何使用 Messagebox 在 Windows 7 任务调度程序中启动 VBS 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆