Service update works but not as expected

My app is a service and I call wyUpdate via command line from it. That works great on Windows XP. On Windows 7 I'm having the following behavior:

1. The new version is being detected fine, the update starts, my service is brought down as expected.2. The actual update is not happening. If I run wyUpdate manually it offers to upgrade and that upgrade works fine.3. If I restart my service manually and it repeats calls to wyUpdate then the update completes too. My service is properly restarted.

Here is my code (in my Windows service):

Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo();

startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.FileName = path; startInfo.Arguments = "/quickcheck /justcheck /noerr"; process.StartInfo = startInfo; process.Start();

while (!process.WaitForExit(1000)) { }

if (process.ExitCode == 2) { startInfo.Arguments = "/fromservice"; process.Start(); }

I'm not sure how to troubleshoot this as there are no logs and I don't know why the update doesn't start the 1st time the service is brought down and it works the 2nd time. I'd tried to stop all my threads in the service ahead of time to make sure it reacts quickly to the Stop command but that doesn't help.

The problem is you're only waiting 1000 ms (1 sec) for the process to exit. Don't do that. Just wait infinite time.

There is loop around the method which in effect waits indefinitely.

I need more information to help you. My guess is that this is causing the problem:

startInfo.WindowStyle = ProcessWindowStyle.Hidden

Don't use that when you start wyUpdate because it causes problems in how threads are run. Also, you probably should re-use a Process class. Just create a new Process class everytime you start a new process.