?
Solved

VB.NET Windows Service Not Runnign Code

Posted on 2009-07-14
6
Medium Priority
?
143 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 500 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

777 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