2014-06-27 103 views
0

我只是想用html Js打開一個notepade.exe,我試過了這段代碼,但它不工作可以任何一個人幫我解決這個問題。這個文件是run.html !!!我無法使用Javascript打開一個exe文件

<html> 
    <head> 
    <script> 
    alert("hi"); 
    <!-- myWindow.close(); --> 
    var param1var = window.location.search.replace("?", ""); 
    alert(param1var); 
    var oShell = new ActiveXObject("Shell.Application"); 
    var commandtoRun = "C:\\Windows\\notepad.exe"; 
    oShell.ShellExecute(commandtoRun,"","","open","1"); 
    window.close() 
    </script> 
    </head> 
</html> 
+0

定義 「它不工作」。怎麼了?你有錯誤嗎? –

+0

可能重複與http://stackoverflow.com/questions/3152482/running-exe-from-javascript –

+0

我剛用記事本,可以看到在控制檯中的錯誤說:「未捕獲的ReferenceError:ActiveXObject未定義」 –

回答

1

打開Internet Explorer,改變/啓用這兩個設置

Tools > Internet Options > Security > Custom level > ActiveX Controls and plug-ins > Initialize and script ActiveX controls not marked as safe for scripting

Tools > Internet Options > Advanced > Security > Allow Active Content to run in files on My Computer

以防萬一,重新啓動Internet Explorer