Hi,
I am trying to start a process from inside a .NET service. The process is a
simple GUI app, the service will start up the GUI and then stop itself. The
service starts the app, but no GUI appears. However, I can see the
application running in the task manager. I made sure that CreateNoWindow was
set to false and still no GUI appears. If i run the application by double
clicking on it, the GUI appears fine. Here is the code:
Process p = new Process();
p.StartInfo.FileName = _basedir + "DbUpdate.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.StartInfo.CreateNoWindow = false;
p.StartInfo.UseShellExecute = true;
p.Start();
Essentially, I am checking the version of a database and if it is not the
correct version, I want to stop the service and start up the updating
utility. The service runs, starts the process, and exits as expected, but
the GUI does not appear, except as a process in Task Manager. If it matters,
I am executing the code through a class using remoting and it is in the
constructor of the class. Also note that the service exits immediately after
starting the process, although I did not think that would be a problem.
If anyone has any insight into the cause of this problem, it would be very
helpful to me.
-Timothy Shih 3 3033
Timothy,
You have to check the properties of the service, and make sure that the
checkbox that says "allow service to interact with desktop" is checked.
However, this is a bad idea, because you can not guarantee that you always
have an interactive user session to show a GUI for.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Timothy Shih" <ts***@sensicast.com> wrote in message
news:eR**************@TK2MSFTNGP09.phx.gbl... Hi,
I am trying to start a process from inside a .NET service. The process is
a simple GUI app, the service will start up the GUI and then stop itself.
The service starts the app, but no GUI appears. However, I can see the application running in the task manager. I made sure that CreateNoWindow
was set to false and still no GUI appears. If i run the application by double clicking on it, the GUI appears fine. Here is the code:
Process p = new Process(); p.StartInfo.FileName = _basedir + "DbUpdate.exe"; p.StartInfo.WindowStyle = ProcessWindowStyle.Normal; p.StartInfo.CreateNoWindow = false; p.StartInfo.UseShellExecute = true; p.Start();
Essentially, I am checking the version of a database and if it is not the correct version, I want to stop the service and start up the updating utility. The service runs, starts the process, and exits as expected, but the GUI does not appear, except as a process in Task Manager. If it
matters, I am executing the code through a class using remoting and it is in the constructor of the class. Also note that the service exits immediately
after starting the process, although I did not think that would be a problem.
If anyone has any insight into the cause of this problem, it would be very helpful to me.
-Timothy Shih
You may want to consider a ms task/job instead. Ideally a service
shouldnt have a gui dependency
Timothy Shih wrote: Hi,
I am trying to start a process from inside a .NET service. The process is a simple GUI app, the service will start up the GUI and then stop itself. The service starts the app, but no GUI appears. However, I can see the application running in the task manager. I made sure that CreateNoWindow was set to false and still no GUI appears. If i run the application by double clicking on it, the GUI appears fine. Here is the code:
Process p = new Process(); p.StartInfo.FileName = _basedir + "DbUpdate.exe"; p.StartInfo.WindowStyle = ProcessWindowStyle.Normal; p.StartInfo.CreateNoWindow = false; p.StartInfo.UseShellExecute = true; p.Start();
Essentially, I am checking the version of a database and if it is not the correct version, I want to stop the service and start up the updating utility. The service runs, starts the process, and exits as expected, but the GUI does not appear, except as a process in Task Manager. If it matters, I am executing the code through a class using remoting and it is in the constructor of the class. Also note that the service exits immediately after starting the process, although I did not think that would be a problem.
If anyone has any insight into the cause of this problem, it would be very helpful to me.
-Timothy Shih
--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl... Timothy,
You have to check the properties of the service, and make sure that
the checkbox that says "allow service to interact with desktop" is checked. However, this is a bad idea, because you can not guarantee that you always have an interactive user session to show a GUI for.
....and if your service is running under the Local System account (which is
the case most of the time unless you change it to a more restrictive
account), the GUI application you are trying to launch will have all the
Local System account right, which means even more rights than the
Administrator account! Definitely no a good idea. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Trokey |
last post by:
I am having a serious problem connecting to out-of-process COM objects in my windows service application. Whenever I try to create an instance of the COM object, a second instance of the COM server...
|
by: Pradeep |
last post by:
HI
Can we invoke a process in windows Servic
Pradeep
|
by: Julia |
last post by:
Hi,
I have two application which 'evaluate'( New FileStream(path....) relative
path,
when evaluating the path inside a window service it always return something
like
...
|
by: Stu |
last post by:
Hi,
I have been asked to write a little app the restarts a windows service under
certain conditions. It is not a service written in .Net?
thanks in advance,
Stu
|
by: Shane Lowenberger via .NET 247 |
last post by:
Hi All,
I created a Windows Service in Visual Basic.NET and am having troubles. My Service installs fine, but when I start I get two exceptions thrown in the Event Log and the service stops. ...
|
by: Cleyton |
last post by:
Hi!
I would like to know if is it possible start an application through WINDOWS
SERVICE using System.Diagnostics.Process.Start()?
I've tried to do this but nothing happens.
Tks!
|
by: Qais |
last post by:
Hi there all,
i am trying to work on this for past two weeks but nothing seem to
work. I am trying to launch a process from windows service (i have to
do this way, no other option). Windows...
|
by: google |
last post by:
The problematic code runs perfectly fine and unmodified when the
application is executed as a standalone .exe. However when the same
code is executed inside Windows Service - it locks up and waits...
|
by: deepadeshmukh |
last post by:
How to call an external process from Windows service in C#2.0?
This code doesnt works
protected override void OnStart(string args)
{
...
|
by: devonknows |
last post by:
Hi, what im aiming to do is to write a windows service which shuts down a process when a information in a .dat files changes, now the windows service installs, and runs, but.. its not doing the...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |