Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-04-01
6
Medium Priority
?
1,570 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

730 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