Cool Tech Girl

This will be the techie me. Any problems, issues or ideas I come across during my day to day life as a Software Engineer will be posted here.

Google
 
Web This Blog

Tuesday, August 02, 2005

Opening EXE from a web service

One can invoke a exe application from a web service using the Process class, setting its properties and calling process.start. Sometimes you may have problems opening the application because the exe does not give access to the ASPNET user by default. You need to specifically change the permissions on the exe you want to open from a webservice. The ASPNET user is generally computer_name/ASPNET.
Also keep in mind that if your exe writes any files, the ASPNET user needs access to the location or folder where it writes or makes changes. I had a hard time finding this out.
One thing to keep in mind is that a web service will not allow you to see any application opened from it because it is on the server, so the client cannot see it. If you use localhost, you can see that the exe is running in the task manager.

Sample code for opening exe from web service
Dim myProcess As New Process
myProcess.StartInfo.FileName = {"filename.exe" }
With myProcess.StartInfo
.Arguments = {arguments(string)}
.WorkingDirectory = {directory}
.CreateNoWindow = True 'set this to true if you want the exe to execute in the background (wrt. opening from normal app)
.ErrorDialog = True 'if you want your exe to show error}
.RedirectStandardError = True
.RedirectStandardOutput = True
End With
myProcess.Start()
Dim sErr As String = myProcess.StandardError.ReadToEnd()
Dim sOut As String = myProcess.StandardOutput.ReadToEnd()
myProcess.WaitForExit()

0 Comments:

Post a Comment

<< Home