Auto Log off VBscript does not run in scheduled task

Posted on 2014-07-17
Last Modified: 2014-08-06

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.
Question by:Educad
    LVL 9

    Expert Comment

    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).

    Expert Comment

    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.

    Accepted Solution

    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.
    LVL 9

    Expert Comment


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

    Author Closing Comment

    Nothing has been resolved..

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
    If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
    This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
    The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now