Click to See Complete Forum and Search --> : Starting a process from a Windows Service


dhartigan
April 27th, 2006, 07:02 AM
Hi,

I am trying to update a Windows Service as follows:

the service uses the Updater Application Block to check for updates to itself.
if updates are found the service should launch a console application and then stop itself
the console application will download the updated files and copy them to the right location and then restart the service
My problem is that the service is not launching the console application correctly. The application is visible in the Task Manager but not on the taskbar. The application doesn't do anything that it's supposed to.

I know that the code for the console application works fine because it works perfectly if I run it myself of if I launch it from a Windows Forms application.

Is there anything different when starting a process from a service?

The code I use is as follows:

Dim p As New Process
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal
p.StartInfo.FileName = Path.Combine(My.Application.Info.DirectoryPath, "Utilities\UpdateUtility.exe")
p.StartInfo.Arguments = My.Application.Info.AssemblyName
p.Start()
Me.Stop()


Thanks very much,

dhartigan

Shuja Ali
April 27th, 2006, 07:21 AM
Well actually your process (Console Application) does start but it runs in the a non-interactive desktop and thats the reason why you see it in the task manager and do not see it on the desktop.

Actually having a UI in the service is not a good idea, NT Services are supposed to be running without a UI, so probably you should rethink about the way you are doing things.

The solution to your problem will be to have your service interact with the desktop. But I wouldn't do it personally. And also take a look at Q327618 (http://support.microsoft.com/?scid=http%3a%2f%2fwww.support.microsoft.com%2fkb%2f327618%2f) on MS Support.

dhartigan
April 27th, 2006, 07:28 AM
Thanks for that information ShujaAli.


The solution to your problem will be to have your service interact with the desktop. But I wouldn't do it personally.


I have allowed it to interact with the desktop. I've checked the checkbox in Properties -> Logon tab

Can you suggest another approach?