locked
Running script RRS feed

  • Question

  • Hello not sure in what forum to ask this question but I was wondering if it is possible for the task scheduler in windows xp professional to do something while no one is logged on to the comuter?
    • Moved by Max Wang_1983 Tuesday, April 26, 2011 6:31 PM forum consolidation (From:Architecture, Tools, and Process for ISVs)
    Friday, July 14, 2006 2:20 PM

Answers

  • Yes, but the right choice depends on what "something", what tool you use to write your script as well as your requirements for flexibility, security etc. To run a task on a Windows machine without anybody being logged on, you must run as a service and you have 2 main options:

    a) Use the built in "Task Scheduler" service. That service can schedule and execute commands (such as a VB script, exe-files etc). It runs in a shared service process (svchost.exe) by default under the "Local System" account, which means it can do almost anything on the local machine, but nothing on the network or remotre machines.

    b) Program your own service. You can easilly do this using Visual Studio and .NET since there's a project template and a service installer that hides all the dirty details about creating and installing the service so you can focus on the service logic. This option gives you almost unlimited control over the programming logic as well as the security settings (your service runs under an account of your choice and your service can do whatever you allow that account to do)

     

    Saturday, July 15, 2006 6:43 PM
  • To schedule a task use, the "AT" command from the command line. Type AT /? to get help on how to shedule commands, list scheduled commands etc. You can also programatically configure the task scheduler. A lot of info is available here http://msdn.microsoft.com/library/en-us/taskschd/taskschd/task_scheduler_start_page.asp

    The command itself can be a Windows command (such as xcopy), an application (such as ntbackup) or a script you write in Visual Basic Script or a CMD file (in the future there will also be a new PowerShell available with Windows). It can also be a command line application that you write using .NET (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaa/html/getstart_vcsharp.asp).

    For the task to run when no user is logged on, the above commands must obvoiusly not be interactive (i.e. not pop up a dialog and ask for user input). Many commands and applications take responses as parametered input or work with response files.

    There's a lot of info and samples on how to write scripts available at http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

    Tuesday, July 18, 2006 10:33 AM
  • From GUI:
    Goto Control Panel - (Performance & Maintenance if you use category view) - Administrative Tools - Services. It is listed here under the name "Task Scheduler". Here you can start/stop/configure the services, but not schedule tasks.

    From CMD:
    Start (is started by default): net start schedule
    Stop: net stop schedule
    List tasks: at
    Add a simple task to run at 12 every mon & tue: at 12:00 /every:m,t mycommands.cmd
    Delete a task with id 2: at 2 /delete

    Thursday, July 20, 2006 7:56 AM

All replies

  • Yes, but the right choice depends on what "something", what tool you use to write your script as well as your requirements for flexibility, security etc. To run a task on a Windows machine without anybody being logged on, you must run as a service and you have 2 main options:

    a) Use the built in "Task Scheduler" service. That service can schedule and execute commands (such as a VB script, exe-files etc). It runs in a shared service process (svchost.exe) by default under the "Local System" account, which means it can do almost anything on the local machine, but nothing on the network or remotre machines.

    b) Program your own service. You can easilly do this using Visual Studio and .NET since there's a project template and a service installer that hides all the dirty details about creating and installing the service so you can focus on the service logic. This option gives you almost unlimited control over the programming logic as well as the security settings (your service runs under an account of your choice and your service can do whatever you allow that account to do)

     

    Saturday, July 15, 2006 6:43 PM
  • Great thanks for your answer! Do you have any tips on links that tells you how to write an easy script for the task scheduler? Thanks!!
    Tuesday, July 18, 2006 7:38 AM
  • To schedule a task use, the "AT" command from the command line. Type AT /? to get help on how to shedule commands, list scheduled commands etc. You can also programatically configure the task scheduler. A lot of info is available here http://msdn.microsoft.com/library/en-us/taskschd/taskschd/task_scheduler_start_page.asp

    The command itself can be a Windows command (such as xcopy), an application (such as ntbackup) or a script you write in Visual Basic Script or a CMD file (in the future there will also be a new PowerShell available with Windows). It can also be a command line application that you write using .NET (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaa/html/getstart_vcsharp.asp).

    For the task to run when no user is logged on, the above commands must obvoiusly not be interactive (i.e. not pop up a dialog and ask for user input). Many commands and applications take responses as parametered input or work with response files.

    There's a lot of info and samples on how to write scripts available at http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

    Tuesday, July 18, 2006 10:33 AM
  • Thank you very much for your answers. However I just heard that there was something called Task Scheduler but I do not where on the computer that you can find it. I found something in the Control Panel called Scheduled Activities but I suppose that refers to the task already created. Where can you find the Task Scheduler? Thanks again!
    Tuesday, July 18, 2006 2:24 PM
  • From GUI:
    Goto Control Panel - (Performance & Maintenance if you use category view) - Administrative Tools - Services. It is listed here under the name "Task Scheduler". Here you can start/stop/configure the services, but not schedule tasks.

    From CMD:
    Start (is started by default): net start schedule
    Stop: net stop schedule
    List tasks: at
    Add a simple task to run at 12 every mon & tue: at 12:00 /every:m,t mycommands.cmd
    Delete a task with id 2: at 2 /delete

    Thursday, July 20, 2006 7:56 AM