HTA 调用bat脚本

虽然html不能直接调用bat脚本,但是可以使用html的application即hta实现。通过添加按钮,可以实现界面化操作,非常方便,界面如下图。

主要功能如下:

1. 实现界面化操作;

2. 点击其中一个按钮,后台调用相应的功能;

3. 点击脚本按钮,bat脚本开始运行;

4. 可点击open按钮,打开脚本文件,直接编辑;

5. hta文件可编辑,根据自己的需求任意添加新按钮,实现新功能。

hta代码实现如下:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
        <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
        <meta name="ProgId" content="FrontPage.Editor.Document">
        <title>TOOLS</title>
        <style>
        <!--
        body, table, p, td, div,select { font:menu}
        .button {boder:0; HEIGHT: 20px;width:60px;cursor:hand;font:menu}
        -->
        </style>
    </head>

    <body>
        <SCRIPT language="VBScript">
            Sub bat
            Const NORMAL_WINDOW=1
            Set objShell = CreateObject("Shell.Application")
            End Sub
        </SCRIPT><p>
        <SCRIPT language=JavaScript>
            function Run(strPath) {
                exe.value=strPath;
                try {
                    var objShell = new ActiveXObject("wscript.shell");
                    objShell.Run(strPath);
                    objShell = null;
                }
                catch (e){alert('Can not get the file"'+strPath+'". Please check the path and file name. ')}
            }
        </SCRIPT><p>
            <br>Please input the exe: <br>
            <input name=exe type=text size=21>
            <BUTTON style="width: 80px; height: 23px; color: #FFFFFF; background:green;font-size: 15px;font-weight:bolder;border-radius:6px;" class=button onclick="Run(exe.value)">confirm</BUTTON><br>
            <BUTTON style="width: 160px; height: 40px; color: #FFFFFF; background:blue;font-size: 15px;font-weight:bolder;border-radius:6px;" class=button onclick="Run('calc')">calc</BUTTON><br>        
            <BUTTON style="width: 160px; height: 40px; color: #FFFFFF; background:blue;font-size: 15px;font-weight:bolder;border-radius:6px;" class=button onclick="Run('notepad++.exe')">notepad</BUTTON><br>
            <BUTTON style="width: 160px; height: 40px; color: #FFFFFF; background:blue;font-size: 15px;font-weight:bolder;border-radius:6px;" class=button onclick="Run('cmd')">cmd</BUTTON><br>
            <BUTTON style="width: 160px; height: 40px; color: #FFFFFF; background:blue;font-size: 15px;font-weight:bolder;border-radius:6px;" class=button onclick="Run('IEXPLORE.EXE')">IE</BUTTON><br>
            <BUTTON style="width: 160px; height: 40px; color: #FFFFFF; background:blue;font-size: 15px;font-weight:bolder;border-radius:6px;" class=button onclick="Run('mspaint')">paint</BUTTON><br>        
            <BUTTON style="width: 160px; height: 40px; color: #FFFFFF; background:blue;font-size: 15px;font-weight:bolder;border-radius:6px;" class=button onclick="Run('D:\ui_set_bat\all_bat\tbd.bat')">bat</BUTTON>
            <BUTTON style="width: 80px; height: 40px; color: #FFFFFF; background:slategray;font-size: 15px;font-weight:bolder;border-radius:6px;" class=button onclick="Run('notepad++.exe D:\ui_set_bat\all_bat\init.bat')">open</BUTTON><br>
            <BUTTON style="width: 160px; height: 40px; color: #FFFFFF; background:blue;font-size: 15px;font-weight:bolder;border-radius:6px;" class=button onclick="Run('D:\ui_set_bat\all_bat\all_debug_switch.bat')">Debug_Switch</BUTTON><br>
    </body>
</html>

备注:将该文件保存为 *.hta 后缀名,双击运行。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT故事

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值