0

私は HTA を使用しており、システム上のさまざまなプログラムを開くためのさまざまなボタンを作成したいと考えています。

runfile コマンドを使用して 1 つのプログラムを実行することはできましたが、MS Word などの別のボタンを使用して別のプログラムを開くにはどうすればよいでしょうか。

<html>
<head>
    <title>Start Screen</title>
    <HTA:APPLICATION ID="startscreen"
              APPLICATIONNAME="startscreen"
                BORDER="thin"
                BORDERSTYLE="normal"
                CAPTION="yes"
                ICON="ss.ico"
                MAXIMIZEBUTTON="no"
                MINIMIZEBUTTON="yes"
                SCROLL="no"
                SHOWINTASKBAR="yes"
                SINGLEINSTANCE="yes"
                SYSMENU="yes"
                VERSION="1.0"
                Navigable ="yes"
                WINDOWSTATE="normal"
                contextmenu="no" />
    <script type="text/javascript" language="javascript">
        function RunFile() {
        WshShell = new ActiveXObject("WScript.Shell");
        WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
        }
    </script>
</head>
<body>
    <input type="button" value="Run Notepad" onclick="RunFile();"/>
</body>
</html>
4

2 に答える 2

0

これを使用できます

function RunFile(path) {
    WshShell = new ActiveXObject("WScript.Shell");
    WshShell.Run(path, 1, false);
}

 

<input type="button" value="Run Notepad" onclick="RunFile('c:\windows\notepad.exe');"/>
<input type="button" value="Run Paint" onclick="RunFile('c:\windows\system32\mspaint.exe');"/>

または別のアプローチ。アプリ パスの変数を作成する

var notepad = "c:\windows\notepad.exe";
var paint = "c:\windows\system32\mspaint.exe";

それらを関数に渡します

<input type="button" value="Run Notepad" onclick="RunFile(notepad);"/>
<input type="button" value="Run Paint" onclick="RunFile(paint);"/>
于 2013-11-08T23:28:38.163 に答える
0

どうですか

<input type="button" value="Run Notepad"  
    onclick="RunFile('c:/windows/system32/notepad.exe');"
/>

そしてRunFile()機能の適切な変更?

于 2013-11-08T22:01:06.907 に答える