Execute external application from ASP.Net

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
--------------------------------------------------------------------------------------------
 
A

Aidy

Could be lots of things. Remember the user that the process is running
under is the anon IIS user so will have no network access etc, and it can't
interact with the desktop or anything.

That assumes, of course, that you have anon browsing on.

BTW when creating a process you can do this;

System.Diagnostics.Process p = System.Diagnostics.Process.Start( ... );

p.WaitForExit();
 
R

Ralph

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 Sub
---------------------------------------------------------------------------­-----------------

Maybe you need to impersonate a user that has privilages to run the
app.
 
B

bruce barker

you can only run console apps from asp.net, or window apps written to
support running without a window. programs started from a service do not
have access to the desktop, so they can not open a window.

-- bruce (sqlwork.com)
 
G

Guest

Hi All,

I think the problem is dealing with the IE version. The same code if running
in IE 6.0.2900.2096 will work properly.

Understand that new IE very strict with the use of ActiveX object.
Previously I try to process the Excel using ActiveX object method and it
won't work then I only came to this alternative (to call a windows app to
process the Excel file from ASP.Net app).

Maybe I should look into the way to process Excel file without using the
ActiveX object method at all. Heard that this could be done using Office Web
Component. But I'm lacking the idea on the Excel programming using OWC. Could
anyone give me some hint? I need to go to specific cell of some of the
worksheets in Excel to grab the value for processing where the location of
the cell might not always be fixed.

What a nightmare with Excel programming. Appreciate for any help given.
Thanks!
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top