Solved

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

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
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…

739 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