简体   繁体   English

从网站运行hide cmd.exe(使用javascript或VBScript)

[英]Run hide cmd.exe from website (using javascript or VBScript)

Why is the following example not working? 为什么下面的示例不起作用? Additionally, I would like to hide window of cmd.exe in createEmptyFile() function. 另外,我想在createEmptyFile()函数中隐藏cmd.exe的窗口。 The browsers should probably not block this code : 浏览器可能不应阻止此代码:

<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Default Page Title</title>

</head>

<body>
    <script type="text/javascript" language="javascript"> 
      function pingItjs(ipAddress) {
          var oShell = new ActiveXObject("wscript.shell"); 
          oShell.Run("cmd.exe /k ping" + ipAddress); 
      }

      function createEmptyFile() {
          var oShell = new ActiveXObject("wscript.shell"); 
          oShell.Run("cmd.exe /c cd %tmp% && echo hello > EmptyFile"); 
      }
    </script>

<script language="VBScript">
function pingIt(ipAddress)
      set WshShell = CreateObject("WScript.Shell")
      WshShell.Run("cmd.exe /k ping " & ipAddress)
end function
</script>


    <a href="javascript:pingItjs('216.58.215.78')">ping</a>


    <div onclick="call pingIt('216.58.215.78')">ping</div>

    <a href="javascript:createEmptyFile()">ping</a>
</body>
</html>

ActiveX 的ActiveX

The MDN reference states : MDN参考指出

Note : Creating an ActiveXObject on a remote server is not supported in Internet Explorer 9 standards mode, Internet Explorer 10 standards mode, Internet Explorer 11 standards mode, and Windows Store apps or later. 注意 :Internet Explorer 9标准模式,Internet Explorer 10标准模式,Internet Explorer 11标准模式和Windows Store应用程序或更高版本不支持在远程服务器上创建ActiveXObject。

So, unless the script is being run in your local machine, the code will not run. 因此,除非脚本在本地计算机上运行,​​否则代码将不会运行。 It appears that this can be stretched somewhat in the case of intranets, where the MDN says : 对于Intranet, MDN表示

Important : ActiveX objects may present security issues. 重要说明 :ActiveX对象可能会出现安全问题。 To use the ActiveXObject, you may need to adjust security settings in Internet Explorer for the relevant security zone. 若要使用ActiveXObject,您可能需要在Internet Explorer中调整相关安全区域的安全设置。 For example, for the local intranet zone, you typically need to change a custom setting to "Initialize and script ActiveX controls not marked as safe for scripting." 例如,对于本地Intranet区域,通常需要将自定义设置更改为“初始化未标记为安全脚本的ActiveX控件并对其进行脚本编写”。

VBScript VBScript中

VBScript is a proprietary Microsoft language and as such only works in IE. VBScript是一种专有的Microsoft语言,因此只能在IE中使用。 See this Answer . 看到这个答案 This link (from the Answer just referenced) states that VBScript has been deprecated in IE 11 and will not work in IE 11 in Edge mode. 链接 (来自刚刚引用的答案)指出,VBScript在IE 11中已被弃用,并且在Edge模式下的IE 11中将无法使用。

Possibly, this may help you make VBScript work in IE 11 even in Edge compatibility mode, 可能的话,即使在Edge兼容模式下,这也可以帮助您使VBScript在IE 11中工作,

<meta http-equiv="x-ua-compatible" content="IE=10">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM