Running a process from a Windows Service App

J

Jim Bob

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
 
J

Jim Hughes

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.
 
J

Jim Bob

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top