A
A
Alexander Sukhin2016-10-20 08:54:33
Visual Basic
Alexander Sukhin, 2016-10-20 08:54:33

MsgBox (VBA) via Windows AT Scheduler?

Created a reboot.vbs file that reboots the computer after a specified time, but has the ability to cancel the reboot. Double clicking on the file works fine. When added to the scheduler, the restart works, but the MsgBox does not appear, which means there is no way to cancel the restart. What do you advise?
Add to scheduler command:
AT 20:00 /every:M,T,W,Th,F,S,Su c:\reboot.vbs reboot.vbs
file:

Option Explicit
dim WshShell
' Создаем ссылку на объект WscriptShell
set WshShell = WScript.CreateObject("Wscript.Shell")
WshShell.Run "shutdown -r -t 300"
WScript.Sleep (2000)
If MsgBox("До перезагрузки осталось меньше 5-ти минут."+ Chr(13)+ Chr(13)+"Для отмены перезагрузки нажмите ""Нет"" ", vbYesNo+vbExclamation+vbDefaultButton2, "Перезагрузка")=vbNo then
   WshShell.Run "shutdown -a"
end if

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem @Jump, 2016-10-20
@Alexandr_SS

If you run the script yourself, it runs as a user and has access to the desktop.
In the scheduler you run it as system, how will it bring box to your desktop?
Run under the current user and you will be prompted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question