Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WScript popup not working when called by scheduled task

Status
Not open for further replies.

cdogg

Technical User
Jul 30, 2001
7,785
US
I have a scheduled task that is set to run a script under the Local System account. In the script, the following excerpt is having issues:

Code:
Set WshShell = WScript.CreateObject("WScript.Shell")
popup = wshshell.popup(VBCRLF & "	Example text. This message will close in 30 seconds...", 30," Alert",vbSystemModal)

If I run the script manually with an admin account on Windows XP, it works fine. I see the popup message that pauses the script until it is closed or time runs out. If it's run by the scheduled task, it completes successfully, but I don't ever see the popup.

Researching the issue, I'm guessing it has something to do with being run by the Local System account. Is there a way I can modify the Run line in the scheduled task to get it to enable "interaction" and show the popup? Here's what in the task:

[tab]Run: C:\WINDOWS\system32\wscript.exe "C:\Program Files\test\scipt.vbs"
[tab]Start in: wscript.exe

[tab]Run as: NT AUTHORITY/SYSTEM


Seems like a simple issue. Thanks in advance for any comments!

-Carl
"The glass is neither half-full nor half-empty: it's twice as big as it needs to be."

[tab][navy]For this site's posting policies, click [/navy]here.
 
In the Job properties you should have a checkbox named domething like 'Desktop interaction'.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Geates,
I appreciate the advice, but I have tried emptying the field and even entering "C:\Windows\System32\". Regardless of what's in there, the script runs and completes successfully but with the same issue I described above regarding the missing popup. Wscript.exe was placed in there originally by an SCCM Run Advertised package that creates the task during an install.

PHV,
I came across that suggestion as well when I was scouring the net for an answer. However, under the properties of the task, I don't see an option named anything like that (this is WinXP by the way).


-Carl
"The glass is neither half-full nor half-empty: it's twice as big as it needs to be."

[tab][navy]For this site's posting policies, click [/navy]here.
 
Think I figured it out. If I go into the properties of the Task Scheduler service, there's a checkbox there titled "Allow service to interact with desktop". With that checked, the VBS can be run from task scheduler with the popup.

Now I just have to figure out how to temporarily enable that setting within the script (or prior to the script running)!

-Carl
"The glass is neither half-full nor half-empty: it's twice as big as it needs to be."

[tab][navy]For this site's posting policies, click [/navy]here.
 
Please disregard my last post. That did not work. I goofed during testing.

Back to square one.[tab][sad]

-Carl
"The glass is neither half-full nor half-empty: it's twice as big as it needs to be."

[tab][navy]For this site's posting policies, click [/navy]here.
 
I'd be curious in knowing the solution to this as well.
 
The solution I ended up using was to call psexec, a SysInternals tool, which in turn calls wscript to run the script. This works around task scheduler's limitation of no user interaction from the system account.

The workaround works great in XP. However, I've found that it does not work as intended in Windows Vista/7. That's because the newer OS's do not allow interaction to cross between sessions (session 0 cannot display a popup to session 1). As you might know, the system account runs under a different session ID than user accounts. The system account uses 0, but a user may end up getting 1, 2, and so on depending on the number of active accounts logged in (this includes remote desktop sessions). You can force psexec to run under a specific session ID number, but the problem is you never know for sure what the user will be assigned to.

-Carl
"The glass is neither half-full nor half-empty: it's twice as big as it needs to be."

[tab][navy]For this site's posting policies, click [/navy]here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top