I have a service that I want to start a process to run another process.

My code is

Sub ExecuteProcess()
Try
Dim Msg As String = "Download Service has fired"
Dim RunJob As New System.Diagnostics.Process
RunJob.StartInfo.FileName = "Runjob.bat"
RunJob.StartInfo.Arguments = Msg
RunJob.StartInfo.CreateNoWindow = False
RunJob.Start()
Catch ex As Exception
Dim Event1 As New EventLog
Event1.Log = "Application"
Event1.Source = "DownLoad Service"
Event1.WriteEntry("Error in ExecuteProcess. : " & Chr(13)
& ex.ToString)
End Try
End Sub

This code works fine from a non service app. When I run it inside a
service app, I get no errors but it doesn't appear to run.

Is there a way to run in a service?
jwc

*** Sent via Developersdex http://www.developersdex.com ***

Re: Running a process from a Windows Service App by Jim

Jim
Wed Apr 06 06:54:20 CDT 2005

Where is Runjob.bat?

Try using a fully qualified path name.

Services have %windir%\system32 as the current directory

When you are running it with the standalone app, it is probaby in the same
directory as the executable.

"Jim Bob" <nspam@cableone.net> wrote in message
news:OqzYAbhOFHA.3444@tk2msftngp13.phx.gbl...
>I have a service that I want to start a process to run another process.
>
> My code is
>
> Sub ExecuteProcess()
> Try
> Dim Msg As String = "Download Service has fired"
> Dim RunJob As New System.Diagnostics.Process
> RunJob.StartInfo.FileName = "Runjob.bat"
> RunJob.StartInfo.Arguments = Msg
> RunJob.StartInfo.CreateNoWindow = False
> RunJob.Start()
> Catch ex As Exception
> Dim Event1 As New EventLog
> Event1.Log = "Application"
> Event1.Source = "DownLoad Service"
> Event1.WriteEntry("Error in ExecuteProcess. : " & Chr(13)
> & ex.ToString)
> End Try
> End Sub
>
> This code works fine from a non service app. When I run it inside a
> service app, I get no errors but it doesn't appear to run.
>
> Is there a way to run in a service?
> jwc
>
> *** Sent via Developersdex http://www.developersdex.com ***



Re: Running a process from a Windows Service App by Jim

Jim
Wed Apr 06 11:33:56 CDT 2005


RunJob.bat is in C:\Winnt\System32. It may just be me, but
I think it has more to do that it is running in a service. In a non
service, a cmd window pops up for the time the runjob.bat is executing.
In a service app, I see no cmd window.


jwc

*** Sent via Developersdex http://www.developersdex.com ***