【ASP】執行應用程式並帶參數

首先註冊ASPEXEC.DLL(在asp裡要用此元件才能執行)
   b. 解壓縮後,將ASPEXEC.DLL放在C:\Windows\System32下
   c. 開始 > 執行 > regsvr32 aspexec.dll
   d. 給予ASPEXEC.DLL檔IUSR讀取執行權限(檔案按右鍵,點選安全性)
  
程式部分:
 <%
   Set Executor = Server.CreateObject("ASPExec.Execute")
       Executor.Application = Server.MapPath("/pdf") & "/ABC.exe"  '指定要執行的應用程式路徑  
       Executor.Parameters = "TEST"     '執行應用程式所需的參數
       strResult = Executor.ExecuteDosApp
   
       'Debug 用 
       'Response.Write "<pre>" & strResult & "</pre>" 
       'Response.Write "Attempting to execute " & Executor.Application & "<br>"
        strResult1 = Executor.ExecutewinApp
       'Response.Write "The result of this call was: " & strResult1
   Set Executor = Nothing
 %>

補充:
aspexe.ExecuteDosApp : 執行DOS程式,然後返回一個字串作為結果
aspexe.ExecuteWinApp : 執行windows程式,並且立刻返回結果代碼
aspexe.ExecuteWinAppAndWait : 執行windows程式,程式執行成功還會等待指定的timeout時間
  
參考引用:
在asp執行exe檔 (用asp執行應用程式並帶參數)

留言

這個網誌中的熱門文章

【ASP】日期轉換(西元<-->民國)

【VB】使用NPOI元件來匯出Excel--DataTableToExcel

【SQL】符號切割字串變成多欄