asp.net invoke local program call to execute EXE application

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.