Solved

VB.NET Windows Service Not Runnign Code

Posted on 2009-07-14
6
141 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

732 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