调度批量执行000-pp [英] Scheduling a batch execution000-pp
问题描述
我有以下代码向用户弹出一个现在关机或中止的选项。
I have this following code to pop up user with an option to shutdown machine now or abort.
@echo off
shutdown.exe / s / t 120
echo wscript.quit MsgBox("您的机器将在60秒内关闭。单击是立即关闭"或"否中止",4,"关闭提醒")> yesno.vbs
wscript // nologo yesno.vbs
设定值=%errorlevel%
del yesno.vbs
如果"%value%"==" 6" shutdown.exe / s / t 60 / f
如果"%value%"==" 7" shutdown -a
直接运行时,此批处理工作正常。但是当我尝试使用以下命令安排此操作时:
This batch is working perfectly fine when ran directly. But when I try scheduling this using following command :
schtasks / create / sc DAILY / tn SHUTDOWN_REPORTER / tr C:\ Windows \Temp \ ExecuteYesNo.bat / ru "NT AUTHORITY\SYSTEM" / st 16:45:00 / ri 30 / et 22:00:00 / f"
弹出窗口不仅仅是第一个命令 shutdown.exe / s / t 120可以正常工作。
请帮助。我希望在每天晚上8点到晚上10点之间以及每隔30分钟的预定时间内向用户发送相同的弹出窗口。
The pop up doesn't come only the first command shutdown.exe /s /t 120 works. Kindly help. I want the same pop up to come to user on scheduled time between 8:00 P.M to 10:00 P.M and in this span after every 30 min on daily basis.
提前致谢 Abhay
Thanks in advanceAbhay
推荐答案
这个批次在直接运行时工作得很好。但是当我尝试使用以下命令安排此操作时:
This batch is working perfectly fine when ran directly. But when I try scheduling this using following command :
schtasks / create / sc DAILY / tn SHUTDOWN_REPORTER / tr C:\\ \\ Windows \Temp \ ExecuteYesNo.bat / ru"NT AUTHORITY \ SYSTEM" / st 16:45:00 / ri 30 / et 22:00:00 / f"
为什么要创建计划任务使用schtasks.exe通过控制面板有一个更容易使用的图形用户界面?
Why would you create the scheduled task with schtasks.exe when you have a graphical user interface via the Control Panel that is far easier to use?
另请注意,当您在自己以外的帐户下运行脚本时(例如系统帐户)然后任何屏幕输出(例如由msgbox生成的屏幕输出)将对前台帐户不可见。
Note also that when you run a script under an account other than your own (e.g. the System account) then any screen output (e.g. the one generated by msgbox) will be invisible to the foreground account.
这篇关于调度批量执行000-pp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!