We'd like to remind Forumites to please avoid political debate on the Forum... Read More »
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
Task Scheduler - program to start up on weekdays.
Options
Comments
-
debitcardmayhem wrote: »Run it for 00:01 it should run at start I think,I used to do that for iplayer
Yes, I wondered if tasks would run on startup if they had been scheduled to run in the same day before startup. Just tried it, and seems not though.0 -
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!
Thanks John. It took me a little bit of playing around to convert the text file to a batch file, but now it seems to work perfectly, so thanks very much!0
This discussion has been closed.
Confirm your email address to Create Threads and Reply

Categories
- All Categories
- 351.1K Banking & Borrowing
- 253.1K Reduce Debt & Boost Income
- 453.6K Spending & Discounts
- 244.1K Work, Benefits & Business
- 599K Mortgages, Homes & Bills
- 177K Life & Family
- 257.4K Travel & Transport
- 1.5M Hobbies & Leisure
- 16.1K Discuss & Feedback
- 37.6K Read-Only Boards