現在のプロジェクトでは、JavaScriptを使用してボタンのクリックイベントを使用して.batまたは.exeファイルを実行します。以下に示すようにバッチファイルの内容は次のとおりです。温度センサボタンがクリックされたときにTemperatureSensor.exeファイルを開始JavaScriptを使用してボタンクリックイベントに基づいて.exeファイルまたは.batファイルを実行する方法
start "S:\" TemperatureSensor.exe
。 HTMLページの コードを以下に示します。
<!DOCTYPE html>
<html>
<body>
<p>Click the button to make a BUTTON element with text.</p>
<button onclick="window.open('file:///S:/Test.bat')">Temperature Sensor</button>
</body>
</html>
私は温度センサーボタンをクリックすると、それはTEST.BATファイルを実行する必要がありますが、それは単に新しいページで、次の表示:
アム私は行方不明?ボタンクリックイベントを使用して.exeファイルを実行することは可能ですか?
更新日:以下のようになり、HTMLページの コード:私は温度センサーボタンをクリックすると
<!DOCTYPE html>
<html>
<body>
<p>Click the button to make a BUTTON element with text.</p>
<button onclick="myFunction()">Temperature Sensor</button>
<script>
function myFunction() {
var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "C:\\TemperatureSensor.exe";
if (inputparms != "") {
var commandParms = document.Form1.filename.value;
}
// Invoke the execute method.
oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
}
</script>
</body>
</html>
は、それはエラーが表示されます。キャッチされないのReferenceError:ActiveXObjectのはに定義されていません。
を参照してください。http://stackoverflow.com/questions/1880198/how-to-execute-shell-command-in-javascript – guest271314
セキュリティの問題を回避するには、HTAを使用する必要があります。 – Hackoo
@Hackoo詳細を教えてください。 ?? –