asp.net invoke local program call to execute EXE application
There are two ways to execute an application in asp.net, and each of these methods performs the Notepad program in Windows notepad.exe:
1, call Win32 function ShellExecute.
Call the Win32 function ShellExecute.
Add Reference Imports System.Runtime.InteropServices
To declare a function:
<dllimport ("Shell32.dll") > _
Private Shared Function ShellExecute (hwnd as INTPTR, lpoperation as String, Lpfile as String, lpparameters as String, lpdi Rectory as String, nShowCmd as Int32) as IntPtr
End Function
Call:
ShellExecute (IntPtr.Zero, "open", "C:/windows/notepad.exe", Nothing, nothing, 1)
2. Use process classes in the. NET framework.
Adding references
Imports System.Diagnostics
Call:
Dim process as New process () process
. Startinfo.filename = "C:/windows/notepad.exe" note the filename must be appended.
process. Start ()
=============================================
Note: You can get the results you want by running a program written in both of these ways in asp.net2.0. But in asp.net1.1 or earlier versions, you can't get the results you want.
============================================
This is Microsoft for security reasons to ban the operation of the program, you need to do the following two steps to normal operation:
1. Right-click on the desktop: My Computer--management--services and applications--service--iis admin--Properties--Login--Local SYSTEM account--select "Allow interaction with desktop"--OK
Restart the IIS Admin service.
2, open the directory "C:/windows/microsoft.net/framework/v1.1.4322/config" in the Machine.config file,
Find the "ProcessModel" item, the original one of the property is Username= "machine", Change Machine to "system", save the file.