我會盡量保持這個基本。我試圖在服務器端(而不是客戶端)運行一個shell。我已經分解了我的代碼,所以它非常基礎。現在,如果我使用CreateObject(「Wscript.shell」)在客戶端運行它,它將在瀏覽器中'document.write'用戶。Server.CreateObject(「Wscript.Shell」)問題 - 對象服務器需要錯誤? ASP/VBscript錯誤
<script type="text/vbscript" >
Set Shell = CreateObject("WScript.Shell")
Set whoami = shell.exec("whoami")
Set whoamiOutput = whoami.StdOut
strWhoamiOutput = whoamiOutput.ReadAll
document.write strWhoamiOutput
</script>
現在,如果我改變我的代碼在服務器端運行:
<script type="text/vbscript" >
Set Shell = Server.CreateObject("WScript.Shell")
Set whoami = shell.exec("whoami")
Set whoamiOutput = whoami.StdOut
strWhoamiOutput = whoamiOutput.ReadAll
document.write strWhoamiOutput
</script>
我得到了我的瀏覽器告訴我一個錯誤「所需的對象:服務器」在第11行第11行是'Server.CreateObject'行。我在這裏錯過了什麼?
感謝
昨天我確實發現我需要使用response.write,如果我正在執行服務器,我正在嘗試。但你也是對的,我在服務器上遇到了停止運行命令。我的實際腳本試圖執行SQLCMD,當我在服務器上執行它時,這是一個問題。 CMD與服務器帳戶一起運行,而不是我指定的AppPool PIN,它具有運行SQLCMD所需的訪問權限。我在這一點上研究了一些其他的選擇。 –