Need Help: Service Update Itself With Start/Stop

The last (I think) scenerio that we have to accomplish before we can know that wy will work is updating a service, using the wyUpdate.exe to check for and run the update.

The service has to self update, but it's not. The way I have it set up is basically to silent check and update with /fromservice. The check comes back with 2 indicating an update is available but it seems like the update exe never runs. When using the wyBuilder, I added 2 actions to stop and then start the service that needs updating.

It is written in C# but we have other services written in other languages that would have to use wyUpdate.exe to check and update.

Here is my code to check and run the update, which works on every other scenerio I've tested, except a service.

public int CheckForNewUpdate(string updaterPath) { var proc = new Process { StartInfo = new ProcessStartInfo { FileName = updaterPath, Arguments = "/quickcheck /justcheck /noerr", UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = false } };

proc.Start();

while (!proc.HasExited) { System.Threading.Thread.Sleep(50); }

var exitCode = proc.ExitCode;

return exitCode; }

public void SilentUpdate(int exitCode, string updaterPath) { if (exitCode == 0) { //no new update found return; } else if (exitCode == 1) { //error happened while checking for the update // can I get the error to log it? return; }

var proc = new Process { StartInfo = new ProcessStartInfo { FileName = updaterPath, Arguments = "/fromservice",//"/skipinfo", UseShellExecute = true, RedirectStandardOutput = true, CreateNoWindow = false, Verb = "runas" } };

proc.Start(); }

A little help would be greatly appreaciated!

This is wrong:

while (!proc.HasExited){System.Threading.Thread.Sleep(50);}

Just use this:

proc.WaitForExit();
//error happened while checking for the update// can I get the error to log it?

Yes.

Don't use Verb = "runas". Especially not from a service.

As far as your other question, I'm not really sure what you're asking. What specifically isn't working? What's the error code? What's the error?

Thanks for the reply.

There is no error. It either returns a 0 or 2 and when I get a 2, I start the updater which isn't updating. The updater has the 2 actions to stop and start the service and I use the /fromservice switch. The service never stops (verified by a logger in the onstop method), which is why I added the Verb = "runas" because I thought elevated privileges would help. I have the correct service name in the actions. Even if I run the updater manually, the service never stops and the only file that gets updated is the client.wyc file.

PS... The service is set to "Local System".

The service startup type shouldn't matter, should it? It is currently set to manual.

Just don't try to help me, there is no help for my issues. It is always something stupid and an easy oversight. I had the "download site" set to my other test project so it was downloading the file for it, which would explain why it is in the folder now.

This leads me to a question though. Is there a way to set the client.wyc and wyUpdate.exe files to a different file name?