Task Scheduler - program to start up on weekdays.

Chomeur
Chomeur Posts: 2,159 Forumite
Part of the Furniture 1,000 Posts
Is there any way that I can get a programme to run on my computer at startup every weekday? I'm running Windows XP. I know about putting shortcuts in the Startup folder and about the Task Scheduler. The former will operate every day so I can't limit it to weekdays. The latter has an option to set the days of the week that I want it to operate if I schedule the task to run weekly, but then I can't select "on start up", I have to set a specific time, so that doesn't achieve what I want to do either.

Any thoughts?
«1

Comments

  • John_Gray
    John_Gray Posts: 5,837 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Photogenic
    edited 9 March 2012 at 9:14PM
    I would say the answer for the XP Task Scheduler is No.

    You can select Weekly, and set the task to run on Monday...Friday, but you don't get this flexibility when selecting System Startup.

    If you are a whiz with BATch files, you could run a carefully-crafted BATch file at System Startup, and then check whether today was a weekday. If it was, the BATch file would run your intended program; if it was Saturday or Sunday, the BATch file would just terminate.

    Say a little more about what program you want to run, and what folder it's in, and I'll have a go at writing this BATch file!
  • Chomeur
    Chomeur Posts: 2,159 Forumite
    Part of the Furniture 1,000 Posts
    Well, it is "C:\Program Files\Smart Live Spread Bet MT4\terminal.exe". It's a spreadbetting platform which I wouldn't use at weekends because the markets are closed. It's very kind of you to offer to write the BATch file, I wouldn't know how to. But please don't go to too much trouble.
  • John_Gray
    John_Gray Posts: 5,837 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Photogenic
    OK, I'll have a go tomorrow. I presume the terminal.exe program just brings up a window?
  • Chomeur
    Chomeur Posts: 2,159 Forumite
    Part of the Furniture 1,000 Posts
    John_Gray wrote: »
    OK, I'll have a go tomorrow. I presume the terminal.exe program just brings up a window?

    Yes. So far as I'm aware, anyway.
  • debitcardmayhem
    debitcardmayhem Posts: 12,490 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    edited 9 March 2012 at 11:34PM
    Cannot remember for certain but can't you schedule a weekly task using Mon,Tue,etc for 52 weeks (select m-f on the weekly screen)
    4.8kWp 12x400W Longhi 9.6 kWh battery Giv-hy 5.0 Inverter, WSW facing Essex . Aint no sunshine ☀️ Octopus gas fixed dec 24 @ 5.74 + Octopus Intelligent Flux leccy
  • Chomeur
    Chomeur Posts: 2,159 Forumite
    Part of the Furniture 1,000 Posts
    Cannot remember for certain but can't you schedule a weekly task using Mon,Tue,etc for 52 weeks (select m-f on the weekly screen)

    You can, but you can't have it run on startup. Seems a bit of an omission.
  • debitcardmayhem
    debitcardmayhem Posts: 12,490 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    Chomeur wrote: »
    You can, but you can't have it run on startup. Seems a bit of an omission.
    Run it for 00:01 it should run at start I think,I used to do that for iplayer
    4.8kWp 12x400W Longhi 9.6 kWh battery Giv-hy 5.0 Inverter, WSW facing Essex . Aint no sunshine ☀️ Octopus gas fixed dec 24 @ 5.74 + Octopus Intelligent Flux leccy
  • debitcardmayhem
    debitcardmayhem Posts: 12,490 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    edited 10 March 2012 at 12:56AM
    Better yet look here at "AT" http://support.microsoft.com/kb/313565
    and here for XP specifically http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
    edit also schtasks is more powerful (same site under s )

    Oh and good look for your search for employment :cool:
    4.8kWp 12x400W Longhi 9.6 kWh battery Giv-hy 5.0 Inverter, WSW facing Essex . Aint no sunshine ☀️ Octopus gas fixed dec 24 @ 5.74 + Octopus Intelligent Flux leccy
  • John_Gray
    John_Gray Posts: 5,837 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Photogenic
    Sadly all that these commands do is to interface with the task scheduler/scheduled tasks, whose own interface is far more powerful!

    BATch file later today. But I suspect that it will have to be run at Logon, because at System Startup there is no user running and thus no desktop on which to display the window!
  • John_Gray
    John_Gray Posts: 5,837 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Photogenic
    Here you are.

    I assume you're happy with cutting all the code below and pasting it into a NOTEPAD window, then save it as CallTerm.txt into the folder
    C:\Program Files\Smart Live Spread Bet MT4
    When you've saved it there, then rename CallTerm.txt to be CallTerm.bat
    @echo off
    
    :: +--------------+
    :: I CallTerm.bat I   run Terminal.exe on weekdays only
    :: +--------------+
    
    :: this BATch file should be scheduled to run at Logon time
    
    setlocal
    
    :: determine today's day of the week from the subroutine
    ::   (this is a surprisingly complicated procedure!)
    call :Today yy mm dd downame
    
    :: to prevent the date info from displaying, change display=y to display=n
    set display=y
    
    if /i "%display%"=="y" echo %~n0: today, %dd%/%mm%/%yy%, is a %downame% 
    if /i "%display%"=="y" ping -n 6 127.0.0.1>nul
    
    :: THIS NEXT LINE FOR TESTING ONLY - remove when happy it works
    set downame=Monday
    
    :: if the day of the week doesn't begin with an S, then it's a weekday
    ::   so start Terminal.exe, otherwise do nothing
    if not "%downame:~0,1%"=="S" start "" terminal.exe
    
    :: terminate this batch file
    endlocal
    goto :eof
    
    ::-----------------------------------------------------------------------------
    :Today year month day  [day_of_week_name [day_of_week_num [week_of_month_num]]]
    ::
    :: By:   (originally) Ritchie Lawrence, 2002-2003, before whom I bow in awe
    ::       GetDate, DatetoDOW and DayName combined into this file by John Gray
    ::
    :: Args: at least three arguments MUST be supplied
    ::       %1 var to receive year,                 4 digits (by ref)
    ::       %2 var to receive month,                2 digits, 01 to 12 (by ref)
    ::       %3 var to receive day,                  2 digits, 01 to 31 (by ref)
    ::  opt  %4 var to receive day-of-week name,     Monday to Sunday (by ref)
    ::  opt  %5 var to receive day-of-week number,   1 digit, 1 to 7 (by ref)
    ::  opt  %6 var to receive week-of-month number, 1 digit, 1 to 5 (by ref)
    ::                           used for determining the 3rd Wednesday, etc
    
    if .%3==. md;2>nul & goto :eof & :: give errorlevel 1 if fewer than 3 arguments
    ver>nul & :: return errorlevel 0 in future
    setlocal ENABLEEXTENSIONS
    set t=2&if "%date%z" LSS "A" set t=1
    for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo/^|date') do (
      for /f "tokens=%t%-4 delims=.-/ " %%f in ('date/t') do (
        set %%a=%%f&set %%b=%%g&set %%c=%%h))
    if 1%yy% LSS 200 if 1%yy% LSS 170 (set yy=20%yy%) else (set yy=19%yy%)
    if .%4==. endlocal&set %1=%yy%&set %2=%mm%&set %3=%dd%&goto :eof
    :: note that dd and mm MAY have a leading zero, but d and m do not
    set /a d=100%dd%%%100,m=100%mm%%%100
    set /a z=14-m,z/=12,y=yy+4800-z,m=m+12*z-3,dw=153*m+2
    set /a dw=dw/5+d+y*365+y/4-y/100+y/400-2472630,dw%%=7,dw+=1
    for /f "tokens=%dw%" %%a in ('echo/Mon Tues Wednes Thurs Fri Satur Sun') do (
      set nm=%%aday)
    if .%5==. endlocal&set %1=%yy%&set %2=%mm%&set %3=%dd%&set %4=%nm%&goto :eof
    if .%6==. endlocal&set %1=%yy%&set %2=%mm%&set %3=%dd%&set %4=%nm%&set^
      %5=%dw%&goto :eof
    set /a wm=1+d/7
    endlocal&set %1=%yy%&set %2=%mm%&set %3=%dd%&set %4=%nm%&set^
      %5=%dw%&set %6=%wm%&goto :eof
    ::----------------------------------------------------------------------------
    
    Then all you have to do is to set up your scheduled task to run
    "C:\Program Files\Smart Live Spread Bet MT4\CallTerm.bat"
    at Logon time.

    You will see that I have put some debugging information in the BATch file which will keep the Command Prompt window open for a few seconds, whereupon it should disappear and the Terminal window should appear. Also a 'bodge' line so that you can change the day-of-the-week for testing purposes.

    This may be a bit messy to implement, and I hope you know enough to be able to do the bits which I haven't explained.

    Let me know how it goes, or if you have any questions!
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 349.7K Banking & Borrowing
  • 252.6K Reduce Debt & Boost Income
  • 452.9K Spending & Discounts
  • 242.7K Work, Benefits & Business
  • 619.4K Mortgages, Homes & Bills
  • 176.3K Life & Family
  • 255.6K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 15.1K Coronavirus Support Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.