Solved

VB.NET Windows Service Not Runnign Code

Posted on 2009-07-14
6
142 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 143

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Learn about cloud computing and its benefits for small business owners.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

717 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