同一个HTA应用程序中的VBscript和Javascript无法正常工作...... [英] VBscript and Javascript in the same HTA Application not working...

查看:67
本文介绍了同一个HTA应用程序中的VBscript和Javascript无法正常工作......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下HTA应用程序。这是一个较大版本的小版本我想用来包装一堆VBscripts用于AD,硬件,进程等。我希望能够使用复选框扩展HTA的区域,当我想使用那些脚本的类型。 hta显示正确但是,当我点击按钮来触发脚本时,我得到一个"对象不支持这个属性或方法"。错误弹出。



感谢您的帮助!





< html>
< head>
< title>有用的工具< / title>
< HTA:APPLICATION
APPLICATIONNAME ="有用的工具"
SCROLL =" no"
SINGLEINSTANCE =" no"
WINDOWSTATE =" normal" ;
VERSION =" 1.0"
/>
< script language =" javascript" type =" text / javascript">
function HidePart(d){document.getElementById(d).style.display =" none" ;;函数ShowPart(d){document.getElementById(d).style.display =" block" ;;函数CheckboxChecked(b,d)
{
if(b){ShowPart(d); }
else {HidePart(d);



< / script>
< script language =" VBScript">
On Error Resume Next
Sub ProcessInfo
Dim strComputer
strComputer = InputBox ("输入计算机的名称:")
Dim strProcess
strProcess = InputBox("输入要搜索的进程的名称:")

set objWMIService = GetObject(") winmgmts:"&" {impersonationLevel = impersonate}!\\"& strComputer&" \\\\\\\\\\\\


设置colItems = objWMIService.ExecQuery(" Select * from Win32_Process Where Name ='"& strProcess&"'")
对于colItems中的每个oItem

MsgBox" Process Name:" &安培; oItem.Caption
MsgBox" Windows Version:" &安培; oItem.WindowsVersion
MsgBox" Creation Class Name:" &安培; oItem.CreationClassName
MsgBox" Creation Date:" &安培; oItem.CreationDate
MsgBox" Executable Path:" &安培; oItem.ExecutablePath
MsgBox" Execution State:" &安培; oItem.ExecutionState
MsgBox" Install Date:" &安培; oItem.InstallDate
MsgBox" Page Faults:" &安培; oItem.PageFaults
MsgBox" Page File Usage:" &安培; FormatNumber(oItem.PageFileUsage / 1048576,2)& " MB"
MsgBox" Peak PageFile Usage:" &安培; FormatNumber(oItem.PeakPageFileUsage / 1048576,2)& "MB"
MsgBox"峰值虚拟大小:" &安培; FormatNumber(oItem.PeakVirtualSize / 1048576,2)& "MB"

MsgBox"峰值工作集大小:" &安培; FormatNumber(oItem.PeakWorkingSetSize / 1048576,2)& " MB"
MsgBox"状态:" &安培; oItem.Status
Next
End Sub
< / script>
< script language =" VBScript">
Sub Window_onLoad
window.resizeTo 1024,900
End Sub
< / script>
< / head>
< body>
< h1>有用的工具< / h1>
< form>
< p为H.;结果<输入类型= QUOT;复选框"名称= QUOT; mycheckbox"值= QUOT;是" onclick =" CheckboxChecked(this.checked,'checkboxdiv4')">
选中此框以显示处理工具。
< / p>
< div id =" checkboxdiv4" style =" display:none">
< p>
< input type =" button" value =" Process Information"名称= QUOT; run_button"的onClick = QUOT; ProcessInfo">结果< / p为H.结果< / DIV>结果< /形式>结果< / BODY>结果< / HTML>

解决方案

确定 - 我自己想出来了,但是,我想发布解决方案以防其他人偶然发现这个帖子。



我更改了行:



Sub Processinfo



至:



Sub Processinfo_OnClick



然后将触发脚本的代码更改为:



< input name =" ProcessInfo"类型= QUOT按钮" value =" Process Information">



有效。


I have the following HTA application. This is a small version of a larger one I'd like to use to wrap a bunch of VBscripts for AD, hardware, processes, etc. I want to be able to use checkboxes to expand areas of the HTA when I want to use those types of scripts. The hta displays correctly but, when I click the button to fire off the script I get an "object doesn't support this propert or method" error pop-up.

 

Thanks for any help!


 

<html>
<head>
<title>Useful Tools</title>
<HTA:APPLICATION
     APPLICATIONNAME="Useful Tools"
     SCROLL="no"
     SINGLEINSTANCE="no"
     WINDOWSTATE="normal"
     VERSION="1.0"
/>
<script language="javascript" type="text/javascript">
function HidePart(d) { document.getElementById(d).style.display = "none";  }
function ShowPart(d) { document.getElementById(d).style.display = "block"; }
function CheckboxChecked(b,d)
{
   if(b) { ShowPart(d); }
   else  { HidePart(d); }
}
</script>
<script language="VBScript">
On Error Resume Next
 Sub ProcessInfo
Dim strComputer
strComputer = InputBox("Enter the name of the Computer:")
Dim strProcess
strProcess = InputBox("Enter the name of the Process to search for:")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Process Where Name = '" & strProcess & "'")
For Each oItem in colItems
 MsgBox "Process Name: " & oItem.Caption
 MsgBox "Windows Version: " & oItem.WindowsVersion
    MsgBox "Creation Class Name: " & oItem.CreationClassName
    MsgBox "Creation Date: " & oItem.CreationDate
    MsgBox "Executable Path: " & oItem.ExecutablePath
    MsgBox "Execution State: " & oItem.ExecutionState
    MsgBox "Install Date: " & oItem.InstallDate
    MsgBox "Page Faults: " & oItem.PageFaults
    MsgBox "Page File Usage: " & FormatNumber(oItem.PageFileUsage/1048576, 2) & "MB"
    MsgBox "Peak PageFile Usage: " & FormatNumber(oItem.PeakPageFileUsage/1048576, 2) & "MB"
    MsgBox "Peak Virtual Size: " & FormatNumber(oItem.PeakVirtualSize/1048576, 2) & "MB"
    MsgBox "Peak Working Set Size: " & FormatNumber(oItem.PeakWorkingSetSize/1048576, 2) & "MB"
    MsgBox "Status: " & oItem.Status
Next
End Sub
</script>
<script language="VBScript">
    Sub Window_onLoad
        window.resizeTo 1024,900
    End Sub
</script>
</head>
<body>
<h1>Useful Tools</h1>
<form>
<p>
<input type="checkbox" name="mycheckbox" value="yes" onclick="CheckboxChecked(this.checked,'checkboxdiv4')">
Check this box to display Process tools.
</p>
<div id="checkboxdiv4" style="display:none">
<p>
<input type="button" value="Process Information" name="run_button" onClick="ProcessInfo">
</p>
</div>
</form>
</body>
</html>

解决方案

O.K. - I figured it out myself but, figured I'd post the solution in case anyone else stumbles across this thread.

 

I changed the line:

 

Sub Processinfo 

 

to:

 

Sub Processinfo_OnClick

 

and then changed the code that fires off the script to:

 

<input name="ProcessInfo" type="button" value="Process Information">

 

that worked.


这篇关于同一个HTA应用程序中的VBscript和Javascript无法正常工作......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆