faqts : Computers : Programming : Languages : Asp : Asp.net

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

25 of 42 people (60%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

Visual Studio: Visual Basic.net: ASP.NET: Program: Shell: Execute: How to execute a program?

Sep 2nd, 2008 13:09
Max Ivak, Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 24 December 2003 - 00:19 am -------------------

Visual Studio: Visual Basic.net: ASP.NET: Program: Shell: Execute: How 
to execute a program?

---

It looks currently that any executable runs like a service (that is
background process) only.

---

This not showing the window of that process is by design
because of the executable will then run on the server, and it is not
set by default to open a main window for the application.
Applications that display a window will generally not appear to
work, because ASP.NET does not have a desktop to run under.

---

So no window will be opened e.g.

---
---

Method: Use the 'Shell' command.

---

Tried, but did not open a window in ASP.NET:

---

e.g.

Public Sub PROCTest
 Dim ProcID As Integer
 ' Run Calculator.
 ProcID = Shell( "C:\WINDOWS\system32\CALC.EXE", 
AppWinStyle.MaximizedFocus )
End Sub

---

If you run the 'Shell' command it will execute the program, but as a 
process
(e.g. open Microsoft Windows Task Manager) then you see that the
program that you launched is indeed running as a process (see tab
'Processes').

---

I tried also to increase the 'partial trust' of the assembly, but
it had no influence, as far as can tell now.

---
---

Method: Use the 'System.Diagnostics.Process.Start' command

---

Public Sub PROCTest
 ' Run Calculator.
 System.Diagnostics.Process.Start( "C:\WINDOWS\system32\CALC.EXE" )
End Sub

---

This does not open a window in ASP.NET

---

What this programs are able to do depends on the machines security
policy. In general, ASP.NET pages generally should not be able to run
executables. You will possibly have to change or set your security
options.

Internet: see also: Q317012 INFO: Process and Request Identity in 
ASP.NET
http://support.microsoft.com/support/kb/articles/q317/0/12.asp

---

So you could also try to use:

Public Sub PROCTest
 Dim ProcessStartInfo As New System.Diagnostics.ProcessStartInfo()
 ProcessStartInfo.FileName = "C:\WINDOWS\system32\CALC.EXE"
 ProcessStartInfo.Arguments = "" ' your parameters here
 ProcessStartInfo.WorkingDirectory = "C:\WINDOWS\system32\"
 ProcessStartInfo.WindowStyle = ProcessStartInfo.WindowStyle.Maximized
 ProcessStartInfo.UseShellExecute = True
 ProcessStartInfo.CreateNoWindow = False
 System.Diagnostics.Process.Start(ProcessStartInfo)
End Sub

---

or also:

Public Sub PROCTest
 Dim ProcessStartInfo As New System.Diagnostics.ProcessStartInfo()
 ProcessStartInfo.FileName = "iexplore.exe"
 ProcessStartInfo.Arguments = "http://www.faqts.com"
 ProcessStartInfo.WorkingDirectory = ""
 ProcessStartInfo.WindowStyle = ProcessStartInfo.WindowStyle.Maximized
 ProcessStartInfo.UseShellExecute = True
 ProcessStartInfo.CreateNoWindow = False
 System.Diagnostics.Process.Start(ProcessStartInfo)
End Sub

---

This does not open a window in ASP.NET

I tried here also e.g.

       ProcessStartInfo.CreateNoWindow = False

       ProcessStartInfo.CreateNoWindow = True

---

Note:

Tried:

I also tried to run this on a server on the Internet,
and so to check what happens on my local machine.

-If you try this on your local machine, nothing thus happens visually
 (as a result of my trials currently).

-If you try to run this on an Internet server, you probably get
the error 'Runtime Error'
 (e.g. by deploying your program to the server,
  and then typing in a browser:

  e.g.

    
http://www.<yourdomainname.com>/<youraspnetprogramdirectory>/webform1.a
spx

-Checked the 'local security settings' in the administrative tools
 of the control panel. ASPNET seems to be presented OK
 But no window visible after running.

-Changed the 'Username' to 'system' and 'domainname\ASPNET' in the

 file

  \windows\Microsoft.NET\Framework\XXXX\Config\Machine.config file
 (Make a backup first).
 But no window visible after running.

---
---

Note:

If you open Windows task manager, you will see that calc.exe is indeed
running.

The user name is 'ASPNET'.

Thus if you change settings, you should possibly change them for 
ASP.NET.

---
---

Note:

If you create a Windows application instead of a ASP.NET application,
the same code does open the application.

e.g.

1. Create a new Windows project

2. Put a button on the form

3. Double on the button and type this text:

    System.Diagnostics.Process.Start("mspaint.exe")

4. Run this

5. That will start and show the window of Microsoft Paint

but if you repeat this for an ASP.NET project,
no window is shown.

---
---

Help: see also:

---

[[help: see also: program: Microsoft Visual Studio: search for 'Shell']

---
---

Internet: see also:

---

Microsoft.NET: Assembly: Permission: Change: Increase: How to increase 
permissions?
http://www.faqts.com/knowledge_base/index.phtml/fid/1598

---

Microsoft: .NET: Visual Studio: Visual Basic.net: Security: Trust: 
Change: How to change trust?
http://www.faqts.com/knowledge_base/view.phtml/aid/27676/fid/1598

---

Operating system: Microsoft: Control panel: User: View: How view local 
users in computer management?
http://www.faqts.com/knowledge_base/view.phtml/aid/27842/fid/868

---

Web server:IIS: How to set 'Allow service to interact with desktop' on 
Microsoft Windows XP?
http://www.faqts.com/knowledge_base/view.phtml/aid/27825/fid/868

---

Operating system: Microsoft: Windows: XP: Security: Local: Run: How to 
run local security settings?
http://www.faqts.com/knowledge_base/view.phtml/aid/27833/fid/868

---

Operating system: Microsoft: Task manager: Launch: How to run 
Microsoft Windows task manager?
http://www.faqts.com/knowledge_base/view.phtml/aid/27828/fid/772

---

System.Diagnostics.ProcessStartInfo class
http://www.dotnet247.com/247reference/System/Diagnostics/ProcessStartIn
fo.aspx?v=2

---

[Internet: see also: http://www.google.com search for 'how to run an 
executable in asp.net open window': http://groups.google.com/groups?
q=how+to+run+an+executable+in+asp.net&hl=en&lr=&ie=UTF-
8&selm=e71lrjIeDHA.3576%40tk2msftngp13.phx.gbl&rnum=9]

---

[Internet: see also: http://www.google.com search for 'how to run an 
executable in asp.net': http://groups.google.com/groups?
hl=en&lr=&ie=UTF-8&threadm=ef0a04d7.0310220756.58aa7dcd%
40posting.google.com&rnum=2&prev=/groups%3Fq%3Dhow%2Bto%2Brun%2Ban%
2Bexecutable%2Bin%2Basp.net%26hl%3Den%26lr%3D%26ie%3DUTF-8%26selm%
3Def0a04d7.0310220756.58aa7dcd%2540posting.google.com%26rnum%3D2]

---

[Internet: see also: http://www.google.com search for 'asp.net class 
process launch property display main window': 
http://www.dotnet247.com/247reference/System/Diagnostics/Process.aspx?
v=2]

----------------------------------------------------------------------


i found this solution:

1. change local policies for APSNET user:
in WinXP: run secpol.msc

go to Local Policies->User Rights Assignment
find "Deny log on locally" and remove ASPNET user from it.

then find "Deny logon locally" and remove ASPNET user from it.


see for details:

[run application from ASP.NET:
http://mxdev.blogspot.com/2008/09/asp-net-run-application-exe-from-aspnet.html]