how to run app from service

G

Guest

Hello,

I'd like to run an application from a windows service.

I followed the instructions on the MS site to create a service but when it
starts Notepad - notepad window is not visible but process is there.
What could be the problem
My service has this code:

Process myProcess = new Process();
myProcess.StartInfo.CreateNoWindow = false;
myProcess.StartInfo.FileName = "notepad.exe";
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
myProcess.Start();


Thanks
Evgueni
 
J

JV

I haven't done this in awhile but I seem to recall that you have to grant
the service permission to interact with the desktop. Keep in mind that
spawned processes will still be child processes to the service.

Try looking in the properties of your Windows Service in the service
manager. I think there's a checkbox to grant this.
 
M

Michael Nemtsev

Hello JV,

Take into account that this checkbox is not available in the next version
of the windows Vista
Calling UI from the services in bad behavior - use Startup user's folder
for this

J> I haven't done this in awhile but I seem to recall that you have to
J> grant the service permission to interact with the desktop. Keep in
J> mind that spawned processes will still be child processes to the
J> service.
J>
J> Try looking in the properties of your Windows Service in the service
J> manager. I think there's a checkbox to grant this.
J>
J> J>---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
M

Michael Nemtsev

Hello Wayfarer,

What the reason for this? You need to understand that service is working
in absolutely different context then user IS. Moreover service starts *before*
user login. It's not so easy to perform what are u trying to do and this
is a bad behavior (iterating services with desctop options is removed in
the forthcoming version of windows).
I recomend u to put user depended code for start in the Starup folder


W> Hello,
W>
W> I'd like to run an application from a windows service.
W>
W> I followed the instructions on the MS site to create a service but
W> when it
W> starts Notepad - notepad window is not visible but process is there.
W> What could be the problem
W> My service has this code:
W> Process myProcess = new Process();
W> myProcess.StartInfo.CreateNoWindow = false;
W> myProcess.StartInfo.FileName = "notepad.exe";
W> myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
W> myProcess.Start();
W> Thanks
W> Evgueni
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
G

Guest

Hello Michael,

The reason for that is to have a service wrapper that word run all the time
and
download-run another application on changed network conditions i.e. new ip
address.
An additional question is there an event about ip address change?
May be it doable via WMI?

Thanks
Evgueni
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top