<

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

    Published by


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

    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: 8817
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: 8830
Size:  55.7 KB Name:  Capture2.PNG
Views: 8805
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: 8788
Size:  37.4 KB Name:  Capture4.PNG
Views: 8805
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: 8813
Size:  24.3 KB Name:  Capture6.PNG
Views: 8781
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: 8826
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: 8767
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: 8753
Size:  32.3 KB

    Click OK.

    Name:  Capture10.PNG
Views: 8763
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: 8762
Size:  61.7 KB

    Click OK.

    Name:  Capture12.PNG
Views: 8772
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: 8789
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.
  2. #1


    Somewhere Over The Rainbow
    Posts : 4,115
    Windows 7 Ultimate x64/Windows 8 Consumer Preview x64/Ubuntu 11.04


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

      My System SpecsSystem Spec

  3. #2


    Posts : 4
    windows 8.1


    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
Task Scheduler Issues
Hey guys, sorry to start my first post with a question, but I've looked and don't see the answer anywhere. I'll try and be as concise as I can be. Installed speedfan, set it up and all works good. Put a link to it into the startup folder so the program would auto run at startup. This...
General Support
Unidentified task from task scheduler
Does anyone know what the task "CreateObjectTask" is coming from? I can't find it anywhere. https://www.dropbox.com/sc/cull9jreyk7s5gr/AADtnA2TRmshbLHDDi_4wPLQa
General Support
Task Scheduler works in XP but not in 8
I am able to open a document using task scheduler in my Windows XP machine, but not in my Windows 8.1 machine or my daughters Windows 8 machine. Is this a Windows 8 bug? I am able to open the document by hand, but when I wait for the time that Task Scheduler has assigned to open the document,...
General Support
Launch Task Manager Minimized from Task Scheduler
I've added task manager to my scheduled tasks at logon. Everywhere I google, they say to put the /min or -minimized arguments in it to launch it minimized, except neither option works for me. Task Manager launches, but just sits there on my desktop. Is there a new argument for minimized in...
Performance & Maintenance
PC not waking up with task scheduler
Can anyone help troubleshoot why the pc isn't waking when a task is scheduled to wake it? It sleeps, S3, I can wake with the power button, and can WOL, but a task set to wake it is not working. Allow wake timers is enabled in power configuration, and BIOS settings are correct as it woke up when had...
General Support
Task Scheduler task won't start if user is SYSTEM
del
General Support
Task Scheduler issues
I was wondering if there is a way to shut off certain programs at a certain time without turning the computer off? If so How do you do it?
Performance & Maintenance

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