Need c# windows service program to execute a batch file at a specific time on winserver 2003

If someone has a link to a site that will show me how to write a  c# windows service program to execute a  cmd line .bat batch file at a specific time on windows server 2003?

What I have is a simple .bat file that does a xcopy backup for me. Does the job well. I want to execute it every day at 2am. I was thinking of writing a c# windows service to do it. vb is ok as well. If anyone has a better idea I am interetsed as well.

Charles BaldoSoftware DeveloperAsked:
Who is Participating?
jgordosConnect With a Mentor Commented:
You can use the .net function "shell()"...

There are some wrapper classes available (freeware) on the net to wrap this all up in a pretty little bow for you.

CoyotesITConnect With a Mentor Commented:
Here is a site with a tutorial on creating a c# service app, along with passing a parameter to it. I would recommend you use a parameter for the time you want this to run the batch file.

once the service is installed and running with the configured parameter (time of day you want this process to run) then run the file if the current time equals your parameter i.e. 02:00

using System.Diagnostics.Process.Start("c:\\winnt\\notepad.exe");

CoyotesITConnect With a Mentor Commented:
can i ask why you dont just use a scheduled task?
Charles BaldoSoftware DeveloperAuthor Commented:
Thanks both,

In answer to CoyotesIT. Because I didn't think of it Will look into it. Thast some of the exact feed back I was hoping for.   Also I wanted to learn to write a service. This is as much a learning task, hobby task as a business task.

Thanks to both
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.