Solved

VB.NET Windows Service Not Runnign Code

Posted on 2009-07-14
6
137 Views
Last Modified: 2012-05-07
I have built a windows service that I want to run on every monday and the 2nd and 16th of any given month.  The service installed correctly and when I start/restart the service it runs the code, but it doesn't run it on the Mondays, 2nd, or 16th.  I put my code in below.  Any ideas on why this isn't working.  This is my first windows service I have built.  I am using a global date variable to hold the the current date as the service runs.
EventLog.WriteEntry("Dup Remover Started")

        If Date.Today <> dDate Then

            If DatePart(DateInterval.Weekday, Now()) = vbMonday Or DatePart(DateInterval.Day, Now()) = 16 Or DatePart(DateInterval.Day, Now()) = 2 Then

                'run dup checker

                'Dim CL As New Dupcl.dupClean

                'CL.Cleaner()

                Cleaner()

                EventLog.WriteEntry("Service Started On " & Date.Today)

                dDate = Date.Today

                EventLog.WriteEntry("Service Completed")

            End If

        End If

Open in new window

0
Comment
Question by:bengelhart
6 Comments
 
LVL 11

Accepted Solution

by:
loftyworm earned 125 total points
ID: 24855434
Why make this a service?
If I have something I want to run regularly, I "Schedule Task"
If it has to be a service, then make a batch file to start and stop it, and schedule that.

Otherwise, I would start with updating your ASP.net to 3.5 +patches.
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 125 total points
ID: 24857844
Make this into a windows application and schedule that application in the task scheduler.
0
 

Author Comment

by:bengelhart
ID: 24871696
will give that a try.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 25037622
the code you showed is fine, AFAIK.

however, did you set up some "timed-event" to the service code runs/checks the above regularly?
0
 

Author Comment

by:bengelhart
ID: 25102250
I just scheduled the task and it works fine that way.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Learn about cloud computing and its benefits for small business owners.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now