Educad
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.
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.
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
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.
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.
I also use: shutdown -l instead of logoff.exe.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://technet.microsoft.com/en-us/library/cc725745.aspx
Under number 2, you want to be under "User Configuration" instead of "Computer Configuration".
Under number 2, you want to be under "User Configuration" instead of "Computer Configuration".
ASKER
Nothing has been resolved..
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).