Process.Start Hangs with Service

B

brian.gabriel

I am trying to kick of a DOS program from a VB.Net service. The
program works fine when called from a batch file, and from a Windows
form, but it has problems when called from a service. The program runs
successfully but does not give control back to the service.

After the Process.Start statement no code will execute. The program
has exited and is not shown in process monitor. I am running the
service under an admin account.

See my code below.

Thanks for any help!

Brian


Dim myProcess As New Process

myProcess.StartInfo.FileName = strProcess
myProcess.StartInfo.Arguments = strArguments
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.WorkingDirectory = strPath
myProcess.StartInfo.UseShellExecute = False

Try

'Kick off the program
myProcess.Start()

'No code after here will run!!

' wait until it exits
myProcess.WaitForExit()

LogToFile("Converted File")

Catch ex As Exception

LogToFile(ex.Message & " " & ex.Source)
ErrorHandler(ex.Message & " " & ex.Source)

End Try
 
G

Guest

What code do you have in your batch file? You don't wait for exit when you
exicute it.

You are running your service under admin account, but why not under
LocalSystem?

The process (console app) executes fine using the process.Start method,
doesn't it?

In your code, you are saying 'WaitForExit' & this is holding up your
application. Comment out that line & try again. Or what you can do is make
sure that the console app doesn't have any Read or ReadLine's at the end so
it does exit. That way, you will pass back function to your service.

Let me know your results
 
C

Cor Ligthert

Dave,

There are in this 2 know problems.
A service is not allowed to show on screen
The user of the service should be authorised to start a proces on a certain
workstation.

I never tried this, just found this in the newsgroup.

I hope this helps?

Cor
 

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