Solved

Scheduled Task Runs VBScript but does not display message box created in VBscript

Posted on 2009-04-01
6
1,440 Views
Last Modified: 2013-11-09
I have a VBscript that runs the following line in in a script Warning.vbs:

msgbox "Your computer will shutdown with 10 minutes if you do not press oK",0,"WARNING"

I then create a scheduled task via a command line with the following line:

schtasks /create /ru system /sc onidle /i 230 /tn "Warning Shutdown" /tr "C:\Windows\System32\wscript.exe c:\warning.vbs"

The issue I have is when the VBscript runs as a scheduled task there is a sound to say that it has run but it does not display the message box.

When i run the VBscript without it being a scheduled task the box comes up without error.

I know this is a permissions issue however how do i make the script run and display the message box on the users logged in profile as required.
0
Comment
Question by:markodenev
  • 2
  • 2
6 Comments
 
LVL 47

Expert Comment

by:Donald Stewart
ID: 24046553
Try using cscript instead
0
 

Author Comment

by:markodenev
ID: 24046570
I have used both cscript and Wscript and it still creates the same problem any other ideas
0
 
LVL 47

Accepted Solution

by:
Donald Stewart earned 250 total points
ID: 24046600
yes, I forgot that schtasks doesnt have an /interactive switch, But the "AT" command does

http://www.ss64.com/nt/at.html

doesnt make sense because schtasks is the newer command.
0
 

Author Comment

by:markodenev
ID: 24046680
The only problem will be I only want this command to run when the system has been idle for 4 hours or more which i dont think the AT command will do
0
 
LVL 6

Assisted Solution

by:Justin_W_Chandler
Justin_W_Chandler earned 250 total points
ID: 24130001
You could get the best of both worlds!!!

Use scheduled tasks to create a scheduled task that actually invokes the AT command, which then schedules your required task to run once, in the next minute.

For example,

1. System is idle for 4 hours, which invokes the schtasks command.
2. The scheduled task uses the AT command to create another scheduled task (with the interactive switch) that invokes the VBS script within the next minute.

There is a couple lines of code to get the correct time to schedule the task in. (%vHour%:%vMin% will expand to be the time in one minute)

for /f "tokens=1,2 delims=:" %%A in ('echo %time%') do set vHour=%%A&set vMin=%%B
set /a vMin=%vMin%+1
if %vMin% equ 60 set /a vHour=%vHour%+1&set vMin=00
if %vMin% lss 10 set vMin=0%vMin%

Justin Chandler
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It is only natural that we all want our PCs to be in good working order, improved system performance, so that is exactly how programs are advertised to entice. They say things like:            •      PC crashes? Get registry cleaner to repair it!    …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question