Asp uses the aspexec component to execute exe

Source: Internet
Author: User
Http://hi.baidu.com/kk126/blog/item/e44b6b27afc50407918f9d17.html
Http://www.ly705.cn/blog/archives/20071228/93.html
Http://www.lilu.name/Html/diannaojishu/2008-7/962025.html

The aspexe. dll file is a component that can call asp files to execute server programs. It is very convenient to use. Of course, the server program can also be called through server. createobject ("wscript. shell"), but this is not easy to use.

First, download the file: [Click to browse the file: ASPEXEC. DLL]

The syntax or usage of aspexec. dll is described as follows:

1. register the component in the system. Download the dll file and put it in the system32 directory of the system. Then, enter regsvr32 aspexec. dll in "run". A message indicating that the component is successfully registered appears!

2. First create an object
Set aspexe = server. createobject ("aspexec.exe cute ")

3. specify the name and path of the application to run
Aspexe. application = "notepad.exe"

4. Set the parameters of the running program
Aspexe. parameters = "c: \ autoexec. bat"

5. Specify the timeout time
Aspexe. timeout = 60000 (MS)

6. Set whether to display the window when running the program.
Aspexe. showwindow = true

7. Call different running methods based on different program types
==== This method executes the DOS program, and then returns a string as the result ====
Aspexe. ExecuteDosApp

=== This method executes windows programs. If the program runs successfully, it will wait for the specified timeout time ====
Aspexe. ExecuteWinAppAndWait

==== This method executes the windows program and returns the result code immediately ====
Aspexe. executewinapp

The following is an example:

Dim aspexe, strresult
Set aspexe = server. Createobject ("aspexec.exe cute ")
Aspexe. Application = "notepad.exe"
Aspexe. Parameters = "C: \ autoexec. Bat"
Aspexe. Timeout = 60000
Aspexe. showwindow = true
Response. Write ("try to run the program:" & aspexe. Application & "<br> ")
Strresult = aspexe. executewinapp
Response. Write ("the program running result is:" & strresult)

If the program runs properly, the result displayed on the page is:

Try to run the program: notepad.exe
The running result is: OK

If the result is not OK, the following result is displayed, that is, permission settings.

Server Object error 'asp 0178: 66661'

Server. Createobject Access Error

/Aspexec. asp, row 14

Failed to call server. Createobject when checking the permission. Access to this object is rejected.

The solution is to go to the System32 directory and grant the IUSR _ User read and write permissions to the aspexec. dll file.

The following is an example code for calling a program.

<% @ Language = "VBScript" %> <% Response. buffer = false %> <% dim aspexe, strResultset aspexe = server. createObject ("aspexec.exe cute") aspexe. application = "C: \ Inetpub \ wwwroot \ bpmdetect \ bpmdetect.exe" aspexe. parameters = "C: \ Inetpub \ wwwroot \ bpmdetect \ 1.mp3" aspexe. showwindow = trueresponse. write ("try to run the program:" & aspexe. application & "<br>") strResult = aspexe. executeDosAppresponse. write (strResult) dim resultresult = split (strResult, "") response. write ("the program running result is:" & result (ubound (result)-1) %>

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.