Advanced scheduled task
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: General Discussion
Forum Description: General discussion and chat on any topic.
URL: https://forums.webwiz.net/forum_posts.asp?TID=12969
Printed Date: 01 April 2026 at 1:42pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Advanced scheduled task
Posted By: huwnet
Subject: Advanced scheduled task
Date Posted: 13 December 2004 at 3:06pm
I need to be able to run a certain program at logon depending on the
day either via batch script or scheduled tasks. However scheduled tasks
is not advanced enough to do a specific day AND to run at logon. How
would I create a batch script to do this?
|
Replies:
Posted By: Mart
Date Posted: 13 December 2004 at 3:10pm
|
For that I would write my own program in VB.NET or C#.NET
|
Posted By: Mart
Date Posted: 13 December 2004 at 3:20pm
Something like
Imports System.Diagnostics
Module TaskRunner
Sub Main()
Select Case Now.DayOfWeek
Case DayOfWeek.Friday
Process.Start("myApplication.exe", "myparameter")
Case DayOfWeek.Monday
Process.Start("Monday.exe")
Case DayOfWeek.Saturday
Process.Start("Saturday.exe")
Case DayOfWeek.Sunday
'etc.
Case DayOfWeek.Thursday
'etc.
Case DayOfWeek.Tuesday
'etc.
Case DayOfWeek.Wednesday
'etc.
End Select
End Sub
End Module
|
Then save that as TaskRunner.vb and go into command prompt then type:
%SystemRoot%\Microsoft.NET\Framework\v1.1.4322\vbc.exe /t:exe
/r:System.dll /r:Microsoft.VisualBasic.dll /out:C:\TaskRunner.exe
C:\TaskRunner.vb
replacing the relevant paths
|
Posted By: huwnet
Date Posted: 13 December 2004 at 3:20pm
Thanks I will try it out

|
Posted By: huwnet
Date Posted: 13 December 2004 at 3:26pm
error :
C:\taskrunner.vb(6) : error BC30451: Name 'Now' is not declared.
|
Posted By: huwnet
Date Posted: 13 December 2004 at 3:27pm
full log:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>cd C:\windows
C:\WINDOWS>cd microsoft.net
C:\WINDOWS\Microsoft.NET>cd framework
C:\WINDOWS\Microsoft.NET\Framework>dir
Volume in drive C has no label.
Volume Serial Number is A0D8-4478
Directory of C:\WINDOWS\Microsoft.NET\Framework
11/11/2004 19:14 <DIR> & nbsp; .
11/11/2004 19:14 <DIR> & nbsp; ..
20/02/2003 19:09 & nbsp; 57,344 NETFXSBS10.exe
20/02/2003 18:44 & nbsp; 36,354 NETFXSBS10.hkf
20/02/2003 19:09 & nbsp; 5,120 sbscmp10.dll
14/05/2002 09:42 & nbsp; 5,120 sbs_diasymreader.dll
14/05/2002 09:42 & nbsp; 5,120 sbs_iehost.dll
14/05/2002 09:42 & nbsp; 5,120 sbs_microsoft.jscript.dll
14/05/2002
09:42 & nbsp;
5,632 sbs_microsoft.vsa.vb.codedomprocessor.dll
14/05/2002 09:42 & nbsp; 5,120 sbs_mscordbi.dll
19/07/2002 11:52 & nbsp; 5,120 sbs_mscorrc.dll
14/05/2002 09:42 & nbsp; 5,120 sbs_mscorsec.dll
14/05/2002
09:42 & nbsp;
5,120 sbs_system.configuration.install.dll
14/05/2002 09:42 & nbsp; 5,120 sbs_system.data.dll
14/05/2002
09:42 & nbsp;
5,120 sbs_system.enterpriseservices.dll
27/06/2002 12:45 & nbsp; 5,120 sbs_VsaVb7rt.dll
14/05/2002 09:42 & nbsp; 5,120 sbs_wminet_utils.dll
22/03/2004 21:19 <DIR> & nbsp; v1.0.3705
11/11/2004 19:29 <DIR> & nbsp; v1.1.4322
&nbs p;
15 File(s) 160,770 bytes
&nbs p; 4 Dir(s) 30,362,521,600 bytes free
C:\WINDOWS\Microsoft.NET\Framework>cd v1.1.4322
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>vbc /t:exe /r:System.dll /r:Microso
ft.VisualBasic.dll /out:C:\taskrunner.exe C:\taskrunner.vb
Microsoft (R) Visual Basic .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322.2032
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.
C:\taskrunner.vb(6) : error BC30451: Name 'Now' is not declared.
Select Case Now.DayOfWeek
&nbs p; ~~~
C:\taskrunner.vb(7) : error BC30058: Statements and labels are not valid between
'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Friday
~
C:\taskrunner.vb(8) : error BC30058: Statements and labels are not valid between
'Select Case' and first 'Case'.
&nbs p; Process.Start("Saturday.exe")
~
C:\taskrunner.vb(9) : error BC30058: Statements and labels are not valid between
'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Monday
~
C:\taskrunner.vb(10) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs
p; Process.Start("C:\Program
Files\Mozilla Firefox\firefox.ex
e", "")
~
C:\taskrunner.vb(11) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Saturday
~
C:\taskrunner.vb(12) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Process.Start("Saturday.exe")
~
C:\taskrunner.vb(13) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Sunday
~
C:\taskrunner.vb(14) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Process.Start("Saturday.exe")
~
C:\taskrunner.vb(15) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Thursday
~
C:\taskrunner.vb(16) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Process.Start("Saturday.exe")
~
C:\taskrunner.vb(17) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Tuesday
~
C:\taskrunner.vb(18) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Process.Start("Saturday.exe")
~
C:\taskrunner.vb(19) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Wednesday
~
C:\taskrunner.vb(20) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs
|
Posted By: Mart
Date Posted: 13 December 2004 at 3:42pm
Add
Imports Microsoft.VisualBasic
after the Imports System
|
Posted By: huwnet
Date Posted: 13 December 2004 at 3:51pm

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>cd C:\microsoft.net\framework\v1.1.4322
The system cannot find the path specified.
C:\Documents and Settings\Administrator>cd C:\microsoft.net
The system cannot find the path specified.
C:\Documents and Settings\Administrator>C:\
'C:\' is not recognized as an internal or external command,
operable program or batch file.
C:\Documents and Settings\Administrator>cd C:\
C:\>cd microsoft.net
The system cannot find the path specified.
C:\>cd C:\windows\microsoft.net\framework\v1.1.4322
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>vbc.exe /t:exe /r:system.dll /r:Mic
rosoft.VisualBasic.dll /out:C:\Taskrunner.exe C:\taskrunner.vb
Microsoft (R) Visual Basic .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322.2032
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.
C:\taskrunner.vb(7) : error BC30058: Statements and labels are not valid between
'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Friday
~
C:\taskrunner.vb(8) : error BC30058: Statements and labels are not valid between
'Select Case' and first 'Case'.
&nbs p; Process.Start("Saturday.exe")
~
C:\taskrunner.vb(9) : error BC30058: Statements and labels are not valid between
'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Monday
~
C:\taskrunner.vb(10) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs
p; Process.Start("C:\Program
Files\Mozilla Firefox\firefox.ex
e", "")
~
C:\taskrunner.vb(11) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Saturday
~
C:\taskrunner.vb(12) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Process.Start("Saturday.exe")
~
C:\taskrunner.vb(13) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Sunday
~
C:\taskrunner.vb(14) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Process.Start("Saturday.exe")
~
C:\taskrunner.vb(15) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Thursday
~
C:\taskrunner.vb(16) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Process.Start("Saturday.exe")
~
C:\taskrunner.vb(17) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Tuesday
~
C:\taskrunner.vb(18) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Process.Start("Saturday.exe")
~
C:\taskrunner.vb(19) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Case DayOfWeek.Wednesday
~
C:\taskrunner.vb(20) : error BC30058: Statements and labels are not valid betwee
n 'Select Case' and first 'Case'.
&nbs p; Process.Start("Saturday.exe")
~
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>
|
Posted By: Mart
Date Posted: 13 December 2004 at 3:58pm
|
Thats just the RTE that mucked up the code, remove all the &nbs p; crap
|
Posted By: huwnet
Date Posted: 16 January 2005 at 12:57pm
Done. Now I get this error:
vbc : Command line error BC2008 : no input sources specified
Thanks
|
Posted By: huwnet
Date Posted: 20 January 2005 at 1:25pm
|