Windows 8 and 8.1 Forums


Task Scheduler

  1. #1
    Task Scheduler

    Task Scheduler
    How to create a Logon task using Task Scheduler
    Published by Dwarf is offline
    07 Aug 2011
    Default Task Scheduler

    information   Information
    This Tutorial will show you how to create a Scheduled Logon Task.


    Note   Note
    You should, ideally, perform this Tutorial from within an account with administrative privileges.


    Section ONE

    Open Task Scheduler.

    Click Create Task...

    This will open the following dialogue panel, with the General tab selected. Give the task a suitable Name and Description. Also, change the other settings (if different) to match those shown below.

    Name:  Capture.png
Views: 7243
Size:  48.5 KB

    Click the Triggers tab and then click New...

    Enter the settings as shown below. If you wish, you can set a start date (as shown below), but if you don't want (or need) to, just uncheck the Activate: option. Click OK.

    Note   Note
    You can set a start date and/or end date for the task if you so choose. Just check the appropriate option(s) shown below (Activate: for the start date and/or Expires: for the end date). I suggest that you set the time(s) to 00:00:00 (midnight), and that you check the option(s) Synchronize across time zones.


    Name:  Capture1.PNG
Views: 7249
Size:  55.7 KB Name:  Capture2.PNG
Views: 7223
Size:  40.7 KB

    Click the Actions tab and then click New...

    Enter the settings as shown below (note that you can change the message to whatever you want it to display) and click OK.

    Name:  Capture3.PNG
Views: 7225
Size:  37.4 KB Name:  Capture4.PNG
Views: 7234
Size:  40.2 KB

    Note   Note
    This only provides for a simple text message to be displayed for each user, with each user having the same message. If that is all you require, skip over the next section, but for more flexibility, see below.


    Section TWO

    Instead of choosing Display a message for the Action:, select Start a program instead, as shown below.

    Name:  Capture5.PNG
Views: 7245
Size:  24.3 KB Name:  Capture6.PNG
Views: 7212
Size:  29.0 KB

    Note   Note
    The following blocks of code are what actually carry out the action when the task is triggered. In all cases, replace the data in BLUE with the actual UserName(s) and the data in <GREEN> with the routine to be executed. For the third block of code, you can choose to use the same routine or a different routine. With the last block of code, a different routine should be used for each user.

    With this script, the routine is executed only if the current user IS the user referenced to by MyStr.
    Code:
    Dim StrUser, MyStr
    Set wshNetwork = CreateObject("WScript.Network")
    Set wshShell = CreateObject("WScript.Shell")
    StrUser = wshNetwork.Username
    MyStr = "account"
    If StrComp(StrUser, MyStr, 1) = 0 Then
    wshShell.Run ("<Routine, including path>")
    End If
    In this script, the routine is executed if the current user IS NOT the user referenced to by MyStr.
    Code:
    Dim StrUser, MyStr
    Set wshNetwork = CreateObject("WScript.Network")
    Set wshShell = CreateObject("WScript.Shell")
    StrUser = wshNetwork.Username
    MyStr = "account"
    If StrComp(StrUser, MyStr, 1) <> 0 Then
    wshShell.Run ("<Routine, including path>")
    End If
    With this script, a routine is executed if the current user IS one of the users referenced to by MyStr1 or MyStr2. Note that the routine can be different for each user, and that you may need to adapt the code to fit in with the accounts on your system. For this example, account1 will execute Routine1, account2 will execute Routine2, and account3 will not execute either routine.
    Code:
    Dim StrUser, MyStr1, MyStr2, MyStr3
    Set wshNetwork = CreateObject("WScript.Network")
    Set wshShell = CreateObject("WScript.Shell")
    StrUser = wshNetwork.Username
    MyStr1 = "account1"
    MyStr2 = "account2"
    MyStr3 = "account3"
    If StrComp(StrUser, MyStr1, 1) = 0 Then
    wshShell.Run ("<Routine1, including path>")
    ElseIf StrComp(StrUser, MyStr2, 1) = 0 Then
    wshShell.Run ("<Routine2, including path>")
    End If
    With this script, Routine1 is executed if the current user IS the user referenced to by MyStr. All other users execute Routine2.
    Code:
    Dim StrUser, MyStr
    Set wshNetwork = CreateObject("WScript.Network")
    Set wshShell = CreateObject("WScript.Shell")
    StrUser = wshNetwork.Username
    MyStr = "account"
    If StrComp(StrUser, MyStr, 1) = 0 Then
    wshShell.Run ("<Routine1, including path>")
    Else
    wshShell.Run ("<Routine2, including path>")
    End If
    Note   Note
    If you want to display a simple message, or messages, simply replace wshShell.Run ("<Routine, including path>") with MsgBox "<Message>", vbSystemModal (change <Message> to whatever you want to display).

    All of the above blocks of code are vbscript files, and should be created using Notepad, saving with a .vbs extension. For the purposes of this Tutorial, the file is saved in the root of the C:\ drive as logonscript.vbs, although you can change the name and location if you wish. Just make sure that the name and location are updated above to reflect any changes.

    Since we don't need to change any further settings, click on OK to finish creating the task and close the Task Scheduler.

    Section THREE

    Triggering a task at logon Logon tasks can be set for any user or a specific user or user group. If the user whose logon has triggered the task is not the user in whose security context the task is running, the task will be noninteractive - in other words, essentially invisible. (The user can note the presence of the task - and terminate it - by running Windows Task Manager, going to the Processes tab, clicking Show Processes From All Users, and answering the UAC prompt.)
    To overcome this limitation, follow the steps below.

    Open Task Scheduler, click Task Scheduler Library to bring up the list of tasks, highlight the one you've just created and click Properties to bring up the following dialogue.

    Name:  Capture7.PNG
Views: 7247
Size:  50.1 KB

    We need to change the information under When running this task, use the following user account:, so click on Change User or Group...

    Name:  Capture8.PNG
Views: 7199
Size:  37.8 KB

    Click Object Types... and change the settings so that only Groups is selected, as shown below. (Note that this is optional, it only narrows down the list you have to look through in the next step. If you wish to omit this step, click on Advanced instead and move on to the next step.)

    Name:  Capture9.PNG
Views: 7189
Size:  32.3 KB

    Click OK.

    Name:  Capture10.PNG
Views: 7194
Size:  35.8 KB

    Click Advanced... and then click Find Now. This will bring up a list of items that match the search criteria. Scroll through and highlight Users as shown below.

    Name:  Capture11.PNG
Views: 7200
Size:  61.7 KB

    Click OK.

    Name:  Capture12.PNG
Views: 7215
Size:  37.0 KB

    Click OK. If the next dialogue comes up as shown below, you have been successful. If not, review the above steps to ensure that you haven't missed anything.

    Name:  Capture13.PNG
Views: 7220
Size:  49.4 KB

    Click OK to save the task, and close the Task Scheduler. Regardless of the user logging on, this task will execute and s/he will see the results of it on their screen in their account.

    warning   Warning
    You need to ensure that all users can freely execute the vbscript files created in the implementation of this Tutorial. Failure to do so will result in the code not being able to be executed in one or more accounts. No error message will be given, and, in tasks where a sequential set of actions is to be performed, only those actions preceding will be executed.

    Published by


    Dwarf's Avatar
    The Contemplator
    (1963-2013)
    Join Date: Jul 2009
    Location: Doncaster, UK
    Posts: 638


    Tutorial Tools


  2. #1
    JaidynM's Avatar

    BSOD Kernel Dump Analyst



    Join Date : Jul 2011
    Somewhere Over The Rainbow
    Posts : 5,115
    Windows 7 Ultimate x64/Windows 8 Consumer Preview x64/Ubuntu 11.04
    Australia au victoria


    Great tutorial, Guy! I'll be tipping the scales.


      My System SpecsSystem Spec

  3. #2



    Junior Member

    Join Date : May 2014
    Posts : 4
    windows 8.1
    USA us tennessee


    Thanks, Dwarf!!!! You tried to help me, but I;m too much of a doofus to follow you after this point:

    "Section TWO

    Instead of choosing Display a message for the Action:, select Start a program instead, as shown below."

    Your sample program was sumpn about "logon....." What is that, and how would I go about selecting my target task from a long list of items that are unfamiliar and udecipherable to me? I want to schedule a Norton scan in the wee hours, but I dont see that option listed in my elementary English. And I fear getting into the register like poison!
      My System SpecsSystem Spec

Task Scheduler
Similar Threads
Tutorial Forum
Solved Task Manager General Support
New Task Manager General Support
Using the new Task manager General Support
Windows 8 Task Manager looks good. Windows 8 News
Windows 8 Task Manager Screens Windows 8 News

Eight Forums Android App Eight Forums IOS App Follow us on Facebook

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23