Auto Log off VBscript does not run in scheduled task


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"

      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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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).
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.
EducadAuthor Commented:
When I ran the script manually on client machine, it worked but not through GPO. It is configured under Computer Configuration and gpo is linked to computer ou.

How do I run as the logged on user? I can see author is showing SYSTEM but run as my domain admin account.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

Under number 2, you want to be under "User Configuration" instead of "Computer Configuration".
EducadAuthor Commented:
Nothing has been resolved..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.