Link to home
Start Free TrialLog in
Avatar of Educad
EducadFlag for Australia

asked on

Auto Log off VBscript does not run in scheduled task

Hi,

I am trying to run this test.vbs file through Windows Task scheduler.

set objShell = CreateObject("Wscript.Shell")

result = objShell.PopUp("You are going to be logged off, please save your work",60,"Logoff required", vbExclamation + vbOKCancel)

If result = 2 Then
      Wscript.echo "Logoff aborted"

Else 
      objShell.Run "Logoff.exe"
End If

Open in new window


But when I add this script to scheduled task it does not run. Message says "the task is currently running(0x41301) and nothing is showing on screen.
Avatar of nick2253
nick2253
Flag of United States of America image

I'm assuming you've manually run the script and confirmed that it launches correctly.

You have to run the task as the logged in user.  Otherwise, it runs under the system account, and displays the message there (aka not on the user desktop).
Avatar of TerryZumwalt
TerryZumwalt

I have had some issues with PowerShell and .VB Scripts in task scheduler but resolved them by writing a .bat file which executes the script.  The Batch file just executes the script you are trying to run.  I put the VB file on the root of the server or specified folder and the batch file would contain:  Start C:\%FilePath%\file.vbs   and I typically do not have any issues.

I also use:  shutdown -l  instead of logoff.exe.
ASKER CERTIFIED SOLUTION
Avatar of Educad
Educad
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
http://technet.microsoft.com/en-us/library/cc725745.aspx

Under number 2, you want to be under "User Configuration" instead of "Computer Configuration".
Avatar of Educad

ASKER

Nothing has been resolved..