469,632 Members | 1,732 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

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 1573

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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Laszlo Zsolt Nagy | last post: by
3 posts views Thread by ChrisWinterscheid | last post: by
2 posts views Thread by John | last post: by
7 posts views Thread by Ahmed Perlom | last post: by
3 posts views Thread by Mika M | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.