ArticleDirectory
- Feedback
- Announcement
- Friend
- Comment ranking
- Reading ranking
Reference Lifecycle.
Posted onSonicit reading (3320) Comments (5) EDIT favorites
Execute an application in Asp.netProgramThere are two methods: 1. Call the Win32 function ShellExecute. 2. Use the process class in. NET Framework. Next, I will use these two methods to execute the program notepad.exe in windows.
Create an ASP. NET page default. aspx and put a button on it to enter the default. aspx. CS page and enter the background processing program.
1. Call the Win32 function ShellExecute.
Add reference using system. 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:
ShellExecute (intptr. Zero, " Open " , " C: \ Windows \ notepad.exe " , Null , Null , 1 );
// You can leave a file name without a suffix, for example, "C: \ WINDOWS \ Notepad ".
Program completed
2. Use the process class in. NET Framework
Add reference using system. diagnostics;
Enter the following in the event handler field for the button:Code:
Process = New Process ();
Process. startinfo. filename = " C: \ Windows \ notepad.exe " ;
// The file name must be suffixed.
Process. Start ();
The program is completed.
Note: You can run the programs written in the above two methods in ASP. net2.0. 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 in iis5.0.
The above is reproduced from others' blogs, but one of them is not explained. In win2003 system, the above method can only be used
The process cannot be executed. Solution: In the program pool corresponding to the website, click Properties> ID and change "Network Service" to "local system ", in this way, the EXE called in Asp.net is run locally on the server.
Category: Asp.net green channel: Follow my favorites to contact me
Sonicit
Follow-0
Fans-5 + plus Follow-up 1 0 (Please comment on this article) «blog previous: fastreport for Delphi7 General Installation Method
» Blog post: BCB \ Delphi activeform full introduction feedback # 1st Floor
By Li bind [unregistered user] Hello! Thank you for reading your article.
I did it according to your instructions. my operating system is 2003, but I still can only see the process, not the form, and I wrote VB. EXE program, and then call the Excel file in the program. When I run the program, VB. EXE appears in my task manager and execl, but VB forms are not visible. Is there any way to see the forms?
Thank you.
#2 floor [ Landlord ]
By sonicit vb I don't know much about it. At least it's okay to call other EXE programs. It may be a problem with VB. I guess I can't help you. Supported (0) against (0) # Third Floor
By zhujinhu, I tried it according to your method. The called EXE is not displayed. Only the process is used. Windows2003 is used. Why does it support (0) opposition (0) # 4th floor?
By invoker707 is the server program or client program started? (0) Objection (0) #5 floor
By lqlzxl hello, I also tried it according to your method. In my Windows2003 system, calling EXE is also a reality. Only processes are available. I started a service program. What is the reason? Support (0) Objection (0)Refresh comments refresh page returns to the top of the registered user login before posting comments, please log on or register, visit the website home page. Blog homepage blog news flash programmer recruitment Knowledge BaseLatest it news:
· Miami joins the U.S. entrepreneurial talent competition
· 3D printed skull is expected to be put into clinical treatment
· Is this an air conditioner remote control? $18000 for female mobile phones
· Transfer Apple stream music service iradio or pass-through to summer or even later
· Wang Yin: Talk about grammar
» More news...Latest Knowledge Base articles: · Exploring AWS and azure in cloud computing
· Summary of SQL Server high-performance writing
· How Facebook implements automated backup of Pb-level databases
· Top 10 commands on source code management
· How to become a powerful programmer?
» More knowledge base articles... announcement nickname: sonicit
Age: 5 years and 9 months
Fans: 5
Note: 0
+ Add common links
- My Essays
- My comments
- My participation
- Latest comments
- My tags
Friend
- Rooney technical space
- Shipfi
Comment ranking reading ranking
There are two ways to execute an application in Asp.net: 1. Call the Win32 function ShellExecute. 2. Use the process class in. NET Framework. Next, I will use these two methods to execute the program notepad.exe in windows.
Create an ASP. NET page default. aspx and put a button on it to enter the default. aspx. CS page and enter the background processing program.
1. Call the Win32 function ShellExecute.
Add reference using system. 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:
ShellExecute (intptr. Zero, " Open " , " C: \ Windows \ notepad.exe " , Null , Null , 1 );
// You can leave a file name without a suffix, for example, "C: \ WINDOWS \ Notepad ".
Program completed
2. Use the process class in. NET Framework
Add reference using system. diagnostics;
Enter the following code in the click event handler of the button:
Process = New Process ();
Process. startinfo. filename = " C: \ Windows \ notepad.exe " ;
// The file name must be suffixed.
Process. Start ();
The program is completed.
Note: You can run the programs written in the above two methods in ASP. net2.0. 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 in iis5.0.
The above is reproduced from others' blogs, but one of them is not explained. In win2003 system, the above method can only be used
The process cannot be executed. Solution: In the program pool corresponding to the website, click Properties> ID and change "Network Service" to "local system ", in this way, the EXE called in Asp.net is run locally on the server.