468,242 Members | 1,705 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

Execute external application from ASP.Net

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
--------------------------------------------------------------------------------------------
Feb 9 '07 #1
4 8269
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();
"LBT" <LB*@discussions.microsoft.comwrote in message
news:C2**********************************@microsof t.com...
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
--------------------------------------------------------------------------------------------
Feb 9 '07 #2
On Feb 9, 7:04 am, LBT <L...@discussions.microsoft.comwrote:
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.

Feb 9 '07 #3
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)

LBT wrote:
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
--------------------------------------------------------------------------------------------
Feb 9 '07 #4
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!

"LBT" wrote:
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
--------------------------------------------------------------------------------------------
Feb 13 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Juan Manuel Alegrķa B. | last post: by
4 posts views Thread by Tom | last post: by
2 posts views Thread by Scott Sommerfeldt | last post: by
6 posts views Thread by moongeegee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.