Reputation: 109
i want to start my windows service on every sunday 1.00 A.M.
can anyone help me in this
Upvotes: 0
Views: 2416
Reputation: 2084
The way I do it is like this:
Second, you make a batch file. You just open Notepad, write the line beneath and save it as a .bat.
net start myService
Then you use the Task Scheduler available in Windows Server.
Creating the task is easy, you just need to add a trigger event (every sunday) and an action (starting the batch file you've just created).
I'm not saying it is the best way, but it is a way that will work.
Upvotes: 0
Reputation: 5179
Since the logic should be done once in a week at a particular time use windows task scheduler for your purpose.
If you do not know how to perform this, Create a sample.vbs file, which calls your asp.net page/web service where you perform the logic. Then create a schedule in windows task scheduler to trigger your sample.vbs file.
Please see the steps to create the .vbs file that calls your asp.net page/web service
1.Open notepad and copy the following code in it and save
'Declare variables
Dim objRequest
Dim URL
Set objRequest = CreateObject("Microsoft.XMLHTTP")
'Put together the URL link appending the Variables.
URL = "http://computerName/VirtualDirectoryName/Logic.aspx"
'Open the HTTP request and pass the URL to the objRequest object
objRequest.open "POST", URL , false
'Send the HTML Request
objRequest.Send
'Set the object to nothing
Set objRequest = Nothing
2.Edit the URL="with your virtual directory path to the asp.net page/web service" and save.
3.change the extension from ".txt" to ".vbs" and save.
4.Create a new schedule in windows "Task Scheduler" and point the newly created sample.vbs file which will call the page where your logic is written (http://computerName/VirtualDirectoryName/Logic.aspx) and edit the settings to run once in a week at a particular time.
Upvotes: 0
Reputation: 40497
If it has to run on every sunday 1.00 AM then probably you need a simple program that is run by task scheduler on 1 AM Sunday.
It would be better if you use a timer that fires say every one hour and check what day and time it is. If it is sunday and 1 AM you can disable the timer and carry on with the work you want to do in the service. After the work is done then you should re-enable the timer.
Upvotes: 4
Reputation: 8036
One way could be to use SC command in a batch file which can be scheduled to run from windows standard scheduler.
For more information, see
SC /?
start and stop parameters in particular.
Upvotes: 2