繁体   English   中英

jscript + wsh无法启动notepad.exe,vbscript + wsh无法启动。 为什么?

[英]jscript+wsh can't launch notepad.exe, vbscript+wsh can. Why?

没关系,我解决了。

应该是

<a href="#" onclick="runnp()">Run notepad.exe</a>

原始问题:

我正在尝试编写一个网页,以在本地计算机上启动程序。 为什么只有vbscript版本有效? 单击jscript链接没有任何反应。

<html> 
<head> 
<script language="VBScript">
    Sub RunProgram 
        Set objShell = CreateObject("Wscript.Shell")
        objShell.Run "notepad.exe"
    End Sub
</script> 

<script language="jscript">
    function runnp() {
        File="notepad.exe";
        objShell = new ActiveXObject("WScript.Shell");
        objShell.run(File);
    }
</script> 

</head> 

<body> 
<a href="#" onclick="RunProgram">Run Program</a>
<A href="#" onClick="runnp(); return false;">Run notepad.exe</A>
</body> 
</html>

如何使jscript版本起作用? (XPsp2上的IE8)

这似乎起作用:

<A href="#" onClick="runnp()">Run notepad.exe</A>

我不知道/不明白为什么您的样品不正确!

暂无
暂无

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

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