473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 8465
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Lance | last post by:
Hi All, I would like to read commands from a file and execute them in VB, something like reading str = "hello world" into VB and execute it. Any suggestions will be appreciated. Thanks, Lance
17
by: David Hughes | last post by:
For example, in Python in a Nutshell, Alex Martelli shows how you can run a Windows (notepad.exe) or Unix-like (/bin/vim) text editor using os.spawnv(os.P_WAIT, editor, ) But how would you call...
2
by: Juan Manuel Alegrķa B. | last post by:
Hi group I have been making a windows service to execute an external application. I use a timer control, I can execute the application but does't appear as a normal windows, just I see it in the...
1
by: sandyde2 | last post by:
Hi all, I am writing a java application as a mozilla extension. Because mozilla uses javascript for the frontend, i need the javascript to call my external java application and pass one...
8
by: Greg Fierro | last post by:
I would appreciate any help from anyone with the following: I have an external program (window32 based) that I am executing with the VBA SHELL command. This program produces a text file which I...
4
by: Tom | last post by:
Hi, I wrote a java console program. But, I am not familiar with Swing to write the GUI. I want to use C# to write the GUI, e.g. a start and a stop buttons. When I click the start button, it...
2
by: Scott Sommerfeldt | last post by:
***I am very new to ASP.net*** I have a simple page that gets a users input and then executes an exteranl application to create a support ticket in HEAT using the users input as arguments All I...
1
by: john | last post by:
I'm trying to develop fast, simple, html-based front ends for some Windows application programs. My idea: 1. Use html forms to let users supply run parameters (title, run options, etc.) 2. ...
6
by: moongeegee | last post by:
I have compile my java program as myjava.class. And I can run as "java myjava" without any program. As now, I need to execute myjava.class in javascript. Please shed a light how to execut "java...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.