Solved

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

Posted on 2009-04-01
6
1,407 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now