473,473 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Having a Problem starting an Application from a Service

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 account and the Interact
with the Desktop is Checked. Windows media player seems to
start but then closes almost immediately. I would
appreciate any help.

Thanks,
Glenn

private void InitializeComponent()
{

this.p = new System.Diagnostics.Process();

this.p.EnableRaisingEvents = true;
this.p.StartInfo.FileName = "C:\\Program Files\\Windows
Media Player\\wmplayer.exe";
this.p.StartInfo.RedirectStandardError = true;
this.p.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Maximized;
this.p.StartInfo.UseShellExecute = true;
this.p.SynchronizingObject = this;
this.p.Exited += new System.EventHandler(this.p_Exited);

// Manager
//
this.ServiceName = "Manager";
((System.ComponentModel.ISupportInitialize)
(this.timer1)).EndInit();

}// end of InitializeComponent

private void p_Exited(object sender, System.EventArgs e)
{

try
{
p.Start();
}
catch(Exception e1)
{
MessageBox.Show(e1.Message.ToString
(),"Error",MessageBoxButtons.OK,MessageBoxIcon.Err or);
}
}// end of p_Exited
public void Startup()
{
p.Start();

}
Nov 15 '05 #1
1 1755

Hi Glenn,

In your code, there are something that does not appear clear to me.

1. In service, you can not use MessageBox.Show method.
2. in your p_Exited method, you start the windows media player process
again?

You can debug your service program using the VS.net to attach into the
service's
process to see what happen after the Windows media player start.

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Glenn" <la****@cox.net>
| Sender: "Glenn" <la****@cox.net>
| Subject: Having a Problem starting an Application from a Service
| Date: Fri, 26 Sep 2003 12:40:01 -0700
| Lines: 58
| Message-ID: <13*****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOEZfnrUQuaSoGbR5ObF4RkyDRGGQ==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:187598
| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| 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 account and the Interact
| with the Desktop is Checked. Windows media player seems to
| start but then closes almost immediately. I would
| appreciate any help.
|
| Thanks,
| Glenn
|
|
|
| private void InitializeComponent()
| {
|
| this.p = new System.Diagnostics.Process();
|
| this.p.EnableRaisingEvents = true;
| this.p.StartInfo.FileName = "C:\\Program Files\\Windows
| Media Player\\wmplayer.exe";
| this.p.StartInfo.RedirectStandardError = true;
| this.p.StartInfo.WindowStyle =
| System.Diagnostics.ProcessWindowStyle.Maximized;
| this.p.StartInfo.UseShellExecute = true;
| this.p.SynchronizingObject = this;
|
|
| this.p.Exited += new System.EventHandler(this.p_Exited);
|
| // Manager
| //
| this.ServiceName = "Manager";
| ((System.ComponentModel.ISupportInitialize)
| (this.timer1)).EndInit();
|
| }// end of InitializeComponent
|
| private void p_Exited(object sender, System.EventArgs e)
| {
|
| try
| {
| p.Start();
| }
| catch(Exception e1)
| {
| MessageBox.Show(e1.Message.ToString
| (),"Error",MessageBoxButtons.OK,MessageBoxIcon.Err or);
| }
| }// end of p_Exited
|
|
| public void Startup()
| {
| p.Start();
|
| }
|

Nov 15 '05 #2

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

Similar topics

6
by: Laszlo Zsolt Nagy | last post by:
Sorry, I realized that the import zlib was not executed from my (working) service. So here is the question: why can't I use zlib from a win32 service? Is there any way to make it working? ...
3
by: ChrisWinterscheid | last post by:
We are running DB2 8.1 on AIX 5.2. DB2level shows: DB21085I Instance "db2inst1" uses "32" bits and DB2 code release "SQL08016" with level identifier "02070106". Informational tokens are "DB2...
0
by: BergRD | last post by:
Salutations! New to the forums but have gotten many an idea from lurking over the past few months but alas it's time to begin positing; posting to a problem I cannot seem to resolve. This is a...
2
by: John | last post by:
Hi I have a vb.net service app which I have set to run as user. When I try to install the service via InstallUtil, I provide user/pass for the administrator but the service fails to install. I...
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...
3
by: Mika M | last post by:
I'm programming quite simple Windows Service using C# 2005. I also made setup for it into same solution. When I run setup to install service, it's going fine into C:\Program Files\MyCompany\My...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.