G
Guest
Good day,
I would like to execute an external application from a web form created
using ASP.Net. I'm using System.Diagnostics.Process. It works fine if it is
notepad.exe but it is not able to execute even a simple VB.Net windows
application. No error is being returned. The application just can't be opened
(even it is not found inside Task Manager of my web server). Any idea? I'm
using IE v 6.0.2900.2180.xpsp_sp2_gdr.050301-1519. My code is as follows:
----------------------------------------------------------------------------------------
Private strProg
Private strFolder
Private pProcess As System.Diagnostics.Process
Private Sub Call_External_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Call_External.Click
Dim strProgPath As String
strProg = "VSM_DataCollectorVB.exe"
strFolder = "C:\Inetpub\wwwroot\VSM_DataCollector"
strProgPath = strFolder & "\" & strProg
If System.IO.File.Exists(strProgPath) Then
ShellAndWaitTillFinish()
End If
End Sub
Private Sub ShellAndWaitTillFinish()
Dim bWait As Boolean = True
pProcess = New System.Diagnostics.Process()
With pProcess
.EnableRaisingEvents = True
.StartInfo.WorkingDirectory = strFolder
.StartInfo.FileName = strProg
.Start()
bWait = True
Do While bWait
If .HasExited Then 'has app exited?
bWait = False 'yes, end waiting
Exit Do
End If
.WaitForExit(1000) 'Wait 1 second before check whether the
exe is finished executed
Loop
End With
End Su
--------------------------------------------------------------------------------------------
I would like to execute an external application from a web form created
using ASP.Net. I'm using System.Diagnostics.Process. It works fine if it is
notepad.exe but it is not able to execute even a simple VB.Net windows
application. No error is being returned. The application just can't be opened
(even it is not found inside Task Manager of my web server). Any idea? I'm
using IE v 6.0.2900.2180.xpsp_sp2_gdr.050301-1519. My code is as follows:
----------------------------------------------------------------------------------------
Private strProg
Private strFolder
Private pProcess As System.Diagnostics.Process
Private Sub Call_External_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Call_External.Click
Dim strProgPath As String
strProg = "VSM_DataCollectorVB.exe"
strFolder = "C:\Inetpub\wwwroot\VSM_DataCollector"
strProgPath = strFolder & "\" & strProg
If System.IO.File.Exists(strProgPath) Then
ShellAndWaitTillFinish()
End If
End Sub
Private Sub ShellAndWaitTillFinish()
Dim bWait As Boolean = True
pProcess = New System.Diagnostics.Process()
With pProcess
.EnableRaisingEvents = True
.StartInfo.WorkingDirectory = strFolder
.StartInfo.FileName = strProg
.Start()
bWait = True
Do While bWait
If .HasExited Then 'has app exited?
bWait = False 'yes, end waiting
Exit Do
End If
.WaitForExit(1000) 'Wait 1 second before check whether the
exe is finished executed
Loop
End With
End Su
--------------------------------------------------------------------------------------------