2016-06-13 94 views
0

我似乎無法創造任何外殼相關的對象,而腳本asp.net web頁面用VB無法創建對象外殼

Server.CreateObject("Wscript.Shell") 

CreateObject("shell.application") 

似乎返回相同的錯誤消息。我相信我做了一些我沒有意識到的錯誤。任何人都可以指出我要出錯的地方嗎?

它給出以下錯誤消息

組分「shell.application」不能被創建。公寓螺紋組件只能在帶有<%@ Page aspcompat=true %>頁指令的頁面上創建。

無法創建組件'Wscript.Shell'。公寓螺紋組件只能在帶有<%@ Page aspcompat=true %>頁指令的頁面上創建。

回答

1

MSDN Article for COM Component Compatibility

<%@ Page AspCompat="true" Language="VB" %> 

<script runat="server"> 
    Dim WshShell = Server.CreateObject("Wscript.Shell") 

    Protected Sub doStuff(strCommand, cliint) 
     Select Case cliint 
      Case "cmd" 
       strCommand = "%SYSTEMROOT%\cmd.exe /c " & strCommand & " 2>&1 %SYSTEMROOT%\Logs\some_kind_of.log" 
      Case "ps" 
       'will obviously require you modify execution policies... 
       strCommand = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe " & strCommand & " 2>&1 %SYSTEMROOT%\Logs\some_kind_of.log" 
      Case else 
     End Select 
     WshShell.Run(strCommand) 
    End Sub 
</script> 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
     <div> 
     </div> 
    </form> 
</body> 
</html> 
+0

非常感謝你的幫助。現在我沒有收到任何錯誤,但仍然無法使用帶有shell.application的對象來使用GetDetailsOf函數。你能幫我解決shell.application問題嗎? –

+0

@IshaqSheikMohamed這是一個不同的問題。 – Lankymart

+0

@Lankymart我已經指出我面臨着兩件事情的問題。我無法在其他地方找到任何解決方案 –