将下面代码保存为HTA文件。打开后点击按钮可以调用出计算器。
但如果保存为htm文件则不行。各位高手是否还有其它的处理办法?
或者请指出我的错误所在。
代码如下:
<html>
<head>
<title>Multiple Subroutines</title><HTA:APPLICATION
ID="objHTAHelpomatic"
APPLICATIONNAME="MultipleSubroutines"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
>
</head><SCRIPT Language="VBScript">Sub RunScripts Msgbox "begin run."strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process") errResult = objWMIService.Create("calc.exe", null, null, intCalcID)End Sub</SCRIPT><body>
<input type="button" value="Run outlook" onClick="RunScripts">
</body>
</html>
===================
问题是出现在Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process") 这一句。
但如果保存为htm文件则不行。各位高手是否还有其它的处理办法?
或者请指出我的错误所在。
代码如下:
<html>
<head>
<title>Multiple Subroutines</title><HTA:APPLICATION
ID="objHTAHelpomatic"
APPLICATIONNAME="MultipleSubroutines"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
>
</head><SCRIPT Language="VBScript">Sub RunScripts Msgbox "begin run."strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process") errResult = objWMIService.Create("calc.exe", null, null, intCalcID)End Sub</SCRIPT><body>
<input type="button" value="Run outlook" onClick="RunScripts">
</body>
</html>
===================
问题是出现在Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process") 这一句。
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<SCRIPT language=JavaScript>
function Run(strPath) {
try {
var objShell = new ActiveXObject("wscript.shell");
objShell.Run(strPath);
objShell = null;
}
catch (e){alert('找不到文件"'+strPath+'"(或它的组件之一)。请确定路径和文件名是否正确,而且所需的库文件均可用。')
}
}
</SCRIPT></head>
<body>
<a href="#" onclick="Run('file:///C:/Program%20Files/Foxmail/Foxmail.exe')">aaa
</a>
</body>
</html>
即报了CATCH异常 ?