Javascript 调用active文件

本文介绍了一种使用HTML和内嵌JavaScript实现本地程序调用的方法,通过创建ActiveXObject对象并调用其Run方法,可以实现从网页直接启动如记事本、画图板、计算器等本地应用程序。
<!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) {
            txtExe.value = strPath;
            try {
                var objShell = new ActiveXObject("wscript.shell");
                objShell.Run(strPath);
                objShell = null;
            }
            catch (e) {
                alert('找不到文件"' + strPath + '"(或它的组件之一)。请确定路径和文件名是否正确,而且所需的库文件均可用。')
            }
        } 
    </script>
</head>
<body>
    请输入要运行的程序:<br>
    <input name="txtExe" type="text" size="20" value="regedit">
    <button type="button" onclick="Run(txtExe.value)">
        确定</button>
    <button type="button" onclick="txtExe.value=''">
        重新输入</button><br>
    <button type="button" onclick="Run('C:\\WINDOWS\\system32\\otepad.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\\egedit.exe')">
        注册表</button><br>
    <button type="button" onclick="Run('C:\\WINDOWS\\PCHealth\\HelpCtr\\Binaries\\msconfig.exe')">
        Msconfig</button><br>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值