CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2005
    Posts
    226

    How To Add A Scheduled Task

    How can you do this? I want to have my program run every once in a while but I don't want to make it a service.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How To Add A Scheduled Task

    At /?

    setting sdk environment relative to c:\program files\microsoft sdks\windows\v6.0
    .
    Targeting windows vista x64 debug


    c:\program files\microsoft sdks\windows\v6.0>at /?
    the at command schedules commands and programs to run on a computer at
    a specified time and date. The schedule service must be running to use
    the at command.

    At [\\computername] [ [id] [/delete] | /delete [/yes]]
    at [\\computername] time [/interactive]
    [ /everyate[,...] | /nextate[,...]] "command"

    \\computername specifies a remote computer. Commands are scheduled on the
    local computer if this parameter is omitted.
    Id is an identification number assigned to a scheduled
    command.
    /delete cancels a scheduled command. If id is omitted, all the
    scheduled commands on the computer are canceled.
    /yes used with cancel all jobs command when no further
    confirmation is desired.
    Time specifies the time when command is to run.
    /interactive allows the job to interact with the desktop of the user
    who is logged on at the time the job runs.
    /everyate[,...] runs the command on each specified day(s) of the week or
    month. If date is omitted, the current day of the month
    is assumed.
    /nextate[,...] runs the specified command on the next occurrence of the
    day (for example, next thursday). If date is omitted, the
    current day of the month is assumed.
    "command" is the windows nt command, or batch program to be run.


    C:\program files\microsoft sdks\windows\v6.0>
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: How To Add A Scheduled Task

    Are you looking for the code to create a scheduled task or are you looking for how to create a scheduled task in general. For first question, you should take a look at SCHTASK.EXE, this is a dos command and has a command line switch /Create that will let you create/schedule the tasks. You could also use AT. Just open the command prompt and write SCHTASK /? to see all the options. reading documentation would also help. You can then use the command using Shell in VB.

    For Question2, open control panel, you will see the scheduled tasks icon, double click on it and it will let you manually create scheduled tasks.

  4. #4
    Join Date
    Mar 2005
    Posts
    226

    Re: How To Add A Scheduled Task

    So I have to run a shell command. I can do that. Thanks.

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How To Add A Scheduled Task

    You can call your .exe directly from the Task Scheduler, or else you could write a 3 line .CMD file (New Batch File)
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Mar 2005
    Posts
    226

    Red face Re: How To Add A Scheduled Task

    I try these. Thanks for the suggestions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured