程式設計專區
|
【Windows】Windows
Server-ASP語法與套件
資料來源: 網路節錄 |
前言 |
使用ASP網頁,以指令轉成Word,EXCEL。轉成PDF須要有額外的套件及語法。 |
|
套件: ASPEXCE.DLL |
以下是步驟: |
|
1. |
首先註冊ASPEXEC.DLL(在asp裡要用此元件才能執行)
a. 至http://www.nodevice.com/dll/ASPEXEC_DLL/item1931.html
下載
b. 解壓縮後,將ASPEXEC.DLL放在C:\Windows\System32下
c. 開始 > 執行 > regsvr32 aspexec.dll
d. 給予ASPEXEC.DLL檔IUSR讀取執行權限(檔案按右鍵,點選安全性)
64bit請放在c:\windows\SysWOW64 (在命令提示字元切換到c:\windows\sysWOW64,輸入regsvr32
aspexec.dll) 適用windows7,
windows 2008 |
2. |
程式部分:
<%
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
%>
|
3. |
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = Server.MapPath("/wkhtmltopdf")
& "/wkhtmltopdf.exe" '指定要執行的應用程式路徑
'執行應用程式所需的參數
Executor.Parameters = "--orientation
Landscape D:\PPC\tmpfile\台中都會區鐵路高架捷運化計畫經費管制表.html
D:\ppc\123.pdf"
strResult = Executor.ExecuteDosApp
Set Executor = Nothing |
|
下載 wkhtmltopdf 32bit
| 64
bit |
|
|
|
C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe
http://buy.jlai.com.tw c:\jlai.pdf |
|
|
SERVER |
Widnows Script Host |
|
停用與啟用 Windows Script Host 是一個可以考慮的做法 |
方法一: |
用記事本將以下虛線中的內容存成bat檔,並以系統管理員權限執行即可。
-----------------------停用 Windows Script Host-----------------------
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
Script Host\Settings" /v Enabled /t REG_DWORD
/d 00000000 |
|
如果要重新啟用 Windows Script Host,同樣用記事本將以下虛線中的內容存成bat檔執行。
-----------------------啟用 Windows Script Host-----------------------
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
Script Host\Settings" /v Enabled /f |
|
|
方法二: |
用記事本將以下虛線中的內容存成reg檔,以系統管理員帳號進行匯入。
-----------------------停用 Windows Script Host-----------------------
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
Script Host\Settings] "Enabled"=dword:00000000 |
|
啟用也一樣。記事本將以下虛線中的內容存成reg檔,以系統管理員帳號進行匯入。
-----------------------啟用 Windows Script Host-----------------------
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
Script Host\Settings] "Enabled"=- |
|
|
|
以上有工具軟體 WSH.zip
請下載 |
|
|
驗證方法 |
要驗證WSH是否停用或啟用,可以在 [執行] 內輸入 wscript.exe ,看執行的結果來判斷 |
|
 |
|
出現 "已停用此電腦的 Windows Script Host 存取"
訊息視窗,表示停用WSH |
|
 |
|
如果出現 "Windows Script Host 設定"
視窗,表示未停用WSH |
|
 |
|
|
|
|
|