我有这个hta脚本,当我运行它时,我得到一个错误说“RunFile1未定义”任何人都可以帮我解决这个问题。谢谢。
我的代码:
<body background = "Image.png">
<TITLE>Test GUI</TITLE>
<script type="text/javascript" language="javascript">
function RunFile() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
}
</script>
<script type="text/javascript" language="javascript">
function RunFile2() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("c:/windows/system32/cmd.exe", 1, false);
}
</script>
<script type="text/javascript" language="javascript">
function RunFile3() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("c:/windows/system32/regedit.exe", 1, false);
}
</script>
<script type="text/javascript" language="javascript">
function RunFile4() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("H:\MY GUI 2.hta", 1, false);
}
</script>
<input type="button" value="Option 1 (notepad.exe)" name="run_button" onClick="RunFile()"><p>
<input type="button" value="Option 2 (cmd.exe)" name="run_button" onClick="RunFile2()"><p>
<input type="button" value="Option 3 (regedit.exe)" name="run_button" onClick="RunFile3()"><p>
<input type="button" value="Option 4"(hta-file.hta)" name="run_button" onClick="RunFile4()"><p>
<input type="button" value="Option 5" name="run_button" onClick="TestSub"><p>
<input type="button" value="Option 6" name="run_button" onClick="TestSub"><p>
<input type="button" value="Option 7" name="run_button" onClick="TestSub"><p>
<input type="button" value="Option 8" name="run_button" onClick="TestSub"><p>
<input type="button" value="Option 9" name="run_button" onClick="TestSub"><p>
<input type="button" value="Option 10" name="run_button" onClick="TestSub"><p>
</body>
感谢您的帮助。
答案 0 :(得分:2)
您的功能RunFile(), RunFile2(), ... RunFile4()
,但不是RunFile1()
。你也会从RunFile4()
得到一个错误,你需要转义反斜杠并将一个包含空格的字符串换成双引号,即Run()
中的第一个参数应该是'"H:\\MY GUI 2.hta"'