2016-06-13 41 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我已经指出我面临着两件事情的问题。我无法在其他地方找到任何解决方案 –