JavaScript調用系統exe檔案

來源:互聯網
上載者:User

今天做了一個測試,源碼是相當簡單的,地球人中的編程人員是都知道寫的,可是有個地方卻始終是被忽略的,IE的安全層級要更改,否則會禁止跳出你所調用的系統exe檔案,核心的說了不多說了~~~~~~~~源碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>    <title></title>    <script type="text/javascript">        function Run(strPath) {            //debugger;            exe.value = strPath;            try {                var objShell = new ActiveXObject("wscript.shell");                objShell.Run(strPath);                objShell = null;            }            catch (e) {                alert('找不到檔案"' + strPath + '"(或它的組件之一)。請確定路徑和檔案名稱是否正確,而且所需的庫檔案均可用。')            }        }       </script></head><body>    請輸入要啟動並執行程式:<br>    <input name="exe" type="text" size="20" value="regedit">    <button type="button" onclick="Run(exe.value)">        確定</button>    <button type="button" onclick="exe.value=''">        重新輸入</button><br>    <button type="button" onclick="Run('C:\\WINDOWS\\system32\\notepad.exe')">        記事本</button><br>    <button type="button" onclick="Run('C:\\WINDOWS\\system32\\mspaint.exe')">        畫圖板</button><br>    <button type="button" onclick="Run('C:\\WINDOWS\\system32\\calc.exe')">        計算機</button><br>    <button type="button" onclick="Run('C:\\WINDOWS\\system32\\cmd.exe')">        cmd</button><br>    <button type="button" onclick="Run('C:\\WINDOWS\\regedit.exe')">        註冊表</button><br>    <button type="button" onclick="Run('C:\\WINDOWS\\PCHealth\\HelpCtr\\Binaries\\msconfig.exe')">        Msconfig</button><br></body></html>

  

 

更改安全層級如下:

 

效果如下:

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.