123qweasdzc
Programmer
Hello .
I want to start a process from a Windows Service. To do that I have the following code:
private System.Timers.Timer timer;
private Process process;
private bool isProcessRunning = false;
protected override void OnStart(string[] args)
{
timer = new System.Timers.Timer();
timer.Interval = 5000;
timer.AutoReset = true;
timer.Elapsed += new System.Timers.ElapsedEventHandler(startProcess);
timer.Start();
}
private void startProcess(object sender, System.Timers.ElapsedEventArgs e)
{
if(!isProcessRunning)
{
EventLog.WriteEntry("Process will start...");
isProcessRunning = true;
process = new Process();
process.StartInfo.FileName = @"C:\Program Files\AllMyMovies\allmymovies.exe";
process.Start();
}
}
I cannot understant why the process do not start because the entry "Process will start" is written in the event viewer log. Can someone say what's wrong? I hope so .
Thanks in advance,
Ricardo
I want to start a process from a Windows Service. To do that I have the following code:
private System.Timers.Timer timer;
private Process process;
private bool isProcessRunning = false;
protected override void OnStart(string[] args)
{
timer = new System.Timers.Timer();
timer.Interval = 5000;
timer.AutoReset = true;
timer.Elapsed += new System.Timers.ElapsedEventHandler(startProcess);
timer.Start();
}
private void startProcess(object sender, System.Timers.ElapsedEventArgs e)
{
if(!isProcessRunning)
{
EventLog.WriteEntry("Process will start...");
isProcessRunning = true;
process = new Process();
process.StartInfo.FileName = @"C:\Program Files\AllMyMovies\allmymovies.exe";
process.Start();
}
}
I cannot understant why the process do not start because the entry "Process will start" is written in the event viewer log. Can someone say what's wrong? I hope so .
Thanks in advance,
Ricardo