I accidentally saw that the. exe application was executed on the webpage.ProgramMethod:
1. Use the process class in. NET Framework
Add referenceUsingSystem. diagnostics;
Enter the following in the event handler field for the button:Code:
Protected void button#click (Object sender, eventargs E)
{
Process pro = new process ();
Pro. startinfo. filename = "C :\\ WINDOWS \ notepad.exe ";
// Suffix can be omitted for file names
Pro. Start ();
}
The program is completed.
2. Call the Win32 function ShellExecute
Add referenceUsingSystem. runtime. interopservices;
Declare a function:
[Dllimport ("shell32.dll")]
Private Static extern intptr ShellExecute (intptr hwnd, string lpoperation, string lpfile, string lpparameters, string lpdirectory, int32 nshowcmd );
In the click event handler of the button, call the previously generated ShellExecute Function:
Protected void button#click (Object sender, eventargs E)
{
ShellExecute (intptr. Zero, "open", "C: \ Windows \ notepad.exe", null, null, 1 );
// The file name can be unsuffixed, for example, "C: \ WINDOWS \ Notepad"
}
Program completed
Note:Run the program written in the above two methods in ASP. net2.0 to get the desired result. However, in ASP. net1.1 or earlier versions cannot get the desired result. When you open the task manager, you can even see that the process already exists (the compiler does not report an error), but the execution effect is not visible, this is why Microsoft banned the running of the Program for security reasons. You need to take the following two steps to run properly:
1. Right-click my computer on the desktop, select Manage, expand the "services and applications" node, and select "services; find the "IIS Admin" item from the service list on the right, right-click the item, select "properties", and open the "login" page in the property box, select "allow desktop interaction" under "Local SYSTEM account" and click "OK. Restart the service.
2. Open the directory "C: \ WINDOWS \ Microsoft. net \ framework \ v1.1.4322 \ config "machine. in the config file, find the "processmodel" item. One of the original attributes of this item is username = "machine", change the machine to "system", save the file, and finish the modification.
Now run the previous program to see the expected results.
The above programs can run normally above iis5.0.
If you have any other good solutions, thank you for your suggestions ~
Communicate and learn together ~