Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-04-01
6
Medium Priority
?
1,618 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
5 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 1000 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 1000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

877 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