473,394 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

starting application with a service.

Hi,

i have just created my first Windows service and it is working great.. my
problem is that I need to start an application in my service:
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
this.frm = new Form1();
this.frm.Show();
}

I can't find my form after starting the service!!! why????
--
LZ
May 2 '06 #1
5 1555
LZ,

In order to do this, you would have to configure your service to
interact with the desktop. However, this is a VERY BAD IDEA. You can't
always be guaranteed that there is an interactive desktop session for your
application to run in.

Rather, if you want an application with a visual component to run when
the user logs in, then you should place the application in the startup
folder, or a registry entry in the "Run" key to auto-launch the program.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Lamis" <La***@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
Hi,

i have just created my first Windows service and it is working great.. my
problem is that I need to start an application in my service:
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
this.frm = new Form1();
this.frm.Show();
}

I can't find my form after starting the service!!! why????
--
LZ

May 2 '06 #2
Hi Nicholas,

I still don't know how to do this interact with the desktop.. do u know
where I can find more details how to make that???? I would like to try the
other thing (place the application in the startup) but I have no idea how to
do that...
--
LZ
"Nicholas Paldino [.NET/C# MVP]" wrote:
LZ,

In order to do this, you would have to configure your service to
interact with the desktop. However, this is a VERY BAD IDEA. You can't
always be guaranteed that there is an interactive desktop session for your
application to run in.

Rather, if you want an application with a visual component to run when
the user logs in, then you should place the application in the startup
folder, or a registry entry in the "Run" key to auto-launch the program.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Lamis" <La***@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
Hi,

i have just created my first Windows service and it is working great.. my
problem is that I need to start an application in my service:
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
this.frm = new Form1();
this.frm.Show();
}

I can't find my form after starting the service!!! why????
--
LZ


May 3 '06 #3
LZ,

Go into the Service Control Manager and find your service. Open up the
property dialog box for it. On the Log On tab you'll see "Allow
service to interact with desktop". Like Nicholas said, this is not a
good idea though.

To place an application in the Startup folder open Explorer and
navigate to "\Documents And Settings\<user>\Start
Menu\Programs\Startup" and drop a shortcut in there.

Brian

Lamis wrote:
Hi Nicholas,

I still don't know how to do this interact with the desktop.. do u know
where I can find more details how to make that???? I would like to try the
other thing (place the application in the startup) but I have no idea how to
do that...
--
LZ


May 3 '06 #4
Hi Brian,
this way works perfectly, thankt you... But unfortunatly I need to do the
same thing without doing it in log On tab, is it possible to do the same
thing in my code so this interaction to desktop would be check when the
service is installed????

--
LZ
"Brian Gideon" wrote:
LZ,

Go into the Service Control Manager and find your service. Open up the
property dialog box for it. On the Log On tab you'll see "Allow
service to interact with desktop". Like Nicholas said, this is not a
good idea though.

To place an application in the Startup folder open Explorer and
navigate to "\Documents And Settings\<user>\Start
Menu\Programs\Startup" and drop a shortcut in there.

Brian

Lamis wrote:
Hi Nicholas,

I still don't know how to do this interact with the desktop.. do u know
where I can find more details how to make that???? I would like to try the
other thing (place the application in the startup) but I have no idea how to
do that...
--
LZ


May 5 '06 #5
LZ,

I don't know. I really recommend against doing this. If you need to
have both a service application running all the time and a GUI
application running when someone is logged in then maybe it's better to
make them two distinct applications that talk to each other via
Remoting or something. There are a lot of issues that come into play
when you allow a service to interact with the desktop directly.

Brian

Lamis wrote:
Hi Brian,
this way works perfectly, thankt you... But unfortunatly I need to do the
same thing without doing it in log On tab, is it possible to do the same
thing in my code so this interaction to desktop would be check when the
service is installed????


May 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Glenn | last post by:
I have used this code successfully in a form application. I tried to add the same code in a service and have not been able to get the application to start. I have the service starting with a local...
3
by: Timothy Shih | last post by:
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...
4
by: Kristof Despiere | last post by:
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example). ...
4
by: hogcods | last post by:
I'm having a strange problem with a service I developed. After installing the service on the target machine, I'm trying to start it using the Services admin window. I get the "Windows is starting"...
7
by: Ahmed Perlom | last post by:
Hi all, I am trying to start a windows application that has a GUI from a Windows service written in .NET 2.0. I have been searching on this for few days now with no avail. When using the...
7
by: | last post by:
Hi to everyone! I have an Apache Webserver running on Win2000. I try to start a console application an the server though PHP, with the functions exec() or passthru() but it doesn't work. The...
5
by: Benzi Eilon | last post by:
I have written a C# application which should run as a Windows Service. I must avoid having multiple instances of the application on one machine so I inserted the following code at the beginning of...
1
by: mikelujan | last post by:
Hi, Our application starts an external application using System.Diagnostics.Process class and the Start() method, as per code snippet below. This application run as a Windows service, and must...
4
by: rottmanj | last post by:
I have written an application that installs a service and then is supposed to start the service. Everything works great except for the service starting(either with AfterIntall or starting it from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.