HTA 中的 VBS 以提取系统信息 [英] VBS in HTA to pull sys info
本文介绍了HTA 中的 VBS 以提取系统信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何将这些字段拉入 HTA 中每个字段的文本框中.我只需要将此信息拉入一个文本框中,即可与其他信息一起显示在我的 HTA 上
How do i pull those fields into a text box for each in an HTA. i just need to pull this info into a text box to display on my HTA along with the rest of the info
Sub getinfo
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
On Error Resume Next
If WScript.Arguments.UnNamed.Count = 1 Then
strComputer = WScript.Arguments.UnNamed(0)
Else
strComputer = "."
End If
Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
Set colInstances = objWMIService.ExecQuery( "SELECT * FROM Win32_ComputerSystem", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly )
For Each objInstance In colInstances
WScript.Echo "Domain : " & objInstance.Domain
WScript.Echo "Manufacturer : " & objInstance.Manufacturer
WScript.Echo "Model : " & objInstance.Model
WScript.Echo "UserName : " & objInstance.UserName
Next
end sub
推荐答案
你可以试试这个 HTA :
You can give a try for this HTA :
<HTA:APPLICATION
BORDERSTYLE = ""
CAPTION="yes"
CONTEXTMENU = "yes"
INNERBORDER = "no"
MAXIMIZEBUTTON = "no"
MINIMIZEBUTTON = "no"
NAVIGABLE = "Yes"
SCROLL = "No"
SCROLLFLAT = "Yes"
SELECTION="Yes"
SYSMENU="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
VERSION = "1.0"
BORDER="thin"
>
<script language="VBScript">
Dim intRamAmt, strCompName, strUserName, strModel
Dim strCPUSpeed, strManufacturer, strAssetTag
Set WSHShell = CreateObject("WScript.Shell")
strComputer = "."
Sub Popup(Msg,Wait,Title)
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("WScript.Shell")
Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2)
Dim tempName : tempName = "Popup.vbs"
Set objOutputFile = fso.CreateTextFile(tempFolder&"\"&tempName, True)
objOutputFile.Writeline "Set WshShell = CreateObject(""WScript.Shell"")"
objOutputFile.WriteLine "BtnCode = WshShell.Popup("&qq(Msg)&","&qq(wait)&","&qq(Title)&",48)"
objOutputFile.Close
ws.Run tempFolder&"\"&tempName
End Sub
Function qq(strIn)
qq = Chr(34) & strIn & Chr(34)
End Function
Sub Window_Onload
window.resizeTo 1,1
Call Popup("Please be patient until loading all informations and the form will be resized !",30,"Please be patient until loading all informations and the form will be resized !")
'##### Get Screen Resolution
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_DisplayConfiguration",,48)
For Each objItem in colItems
intHorizontal = objItem.PelsWidth
intVertical = objItem.PelsHeight
Next
'###### Get UserName, ComputerName, ComputerModel, & RAM
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_ComputerSystem",,48)
For Each objItem In colItems
strCompName = objItem.Name
strUserName = objItem.UserName
strModel = objItem.Model
intRAMamt = Int(objItem.TotalPhysicalMemory / 1048576) & "MB"
Next
'####### Get CPU Information
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_Processor",,48)
For Each ObjItem In ColItems
strCPUSpeed = objItem.CurrentClockSpeed & "MHz"
Next
'####### Get Manufacturer & Serial Number
Set objSysCol = objWMIService.ExecQuery ( _
"Select * from Win32_BIOS",,48)
For Each objSys In ObjSysCol
strManufacturer = Objsys.Manufacturer
strAssetTag = ObjSys.SerialNumber
Next
'####### Get SP Level & OS
Set objSysCol = objWMIService.ExecQuery ( _
"Select * from Win32_OperatingSystem")
For each m In ObjSysCol
strOS = m.caption
strPatchLevelMajor = m.ServicePackMajorVersion
strPatchLevelMinor = m.ServicePackMinorVersion
Next
intSPLevel = strPatchLevelMajor & "." & strPatchLevelMinor
strOS = strOS & " SP " & intSPLevel
'####### Get list of USB devices
Set colDevices = objWMIService.ExecQuery _
("Select * From Win32_USBControllerDevice")
For Each objDevice in colDevices
strDeviceName = objDevice.Dependent
strQuotes = Chr(34)
strDeviceName = Replace(strDeviceName, strQuotes, "")
arrDeviceNames = Split(strDeviceName, "=")
strDeviceName = arrDeviceNames(1)
Set colUSBDevices = objWMIService.ExecQuery _
("Select * From Win32_PnPEntity Where DeviceID = '" & strDeviceName & "'")
For Each objUSBDevice in colUSBDevices
Set objOption = Document.createElement("OPTION")
objOption.Text = objUSBDevice.Name
objOption.Value = objUSBDevice.Name
USBDevices.Add(objOption)
Next
Next
'###### Get last configured NIC w/ IP address
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration" _
& " where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
strMacAddr = IpConfig.MACaddress(i)
strIPAddr = IpConfig.IPAddress(i)
strNetworkCard = Mid(Ipconfig.Caption(i),12,Len(Ipconfig.Caption(i))-11)
Next
If i > 1 Then strIPAddr = strIPaddr & " ( > than 1 IP - check card)"
End If
Exit For
Next
'###### Get complete list of Network Cards
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_NetworkAdapter",,48)
For Each objItem in colItems
Set objOption = Document.createElement("OPTION")
objOption.Text = Mid(ObjItem.Caption,12, Len(ObjItem.Caption)-11)
objOption.Value = Mid(ObjItem.Caption,12, Len(ObjItem.Caption)-11)
NetDevices.Add(objOption)
Next
'###### Get list of Drives
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_LogicalDisk",,48)
For Each objItem in colItems
If objItem.Name <> "A:" Then
Set objOption = Document.createElement("OPTION")
objOption.Text = objItem.Name & "-Total:" & int(objItem.Size / 107526550)*.1 & "GB" & "-Free Space:" & int(objItem.FreeSpace / 107526550)*.1 & "GB"
DiskDevices.Add(objOption)
End IF
Next
frmCompName.InnerHTML = strCompName
frmstrUserName.InnerHTML = strUserName
frmstrManufacturer.InnerHTML = strManufacturer
frmstrModel.InnerHTML = strModel
frmstrAssetTag.InnerHTML = strAssetTag
frmstrCPUSpeed.InnerHTML = strCPUSpeed
frmintRAMamt.InnerHTML = intRAMamt
frmstrOS.InnerHTML = strOS
frmstrMacAddr.InnerHTML = strMacAddr
frmstrIPAddr.InnerHTML = strIPAddr
frmstrNetworkCard.InnerHTML = strNetworkCard
window.resizeTo 640,300
intLeft = (intHorizontal - 640) / 2
intTop = (intVertical - 300) / 2
window.moveTo intLeft, intTop
End Sub
</script>
<html>
<head>
<title>Computer Information</title>
<style type="text/css">
@import "all.css"; /* just some basic formatting, no layout stuff */
body {
background-color:black;
margin:0px 0px 0px 0px;
}
table {
border-width: 0px 0px 0px 0px;
margin:0px 0px 0px 0px;
padding:0px 0px 5px 5px;
border-collapse: collapse;
font-family: arial, Helvetica, sans-serif;
font-size: 75%;
}
.tblborderline {
border-bottom: 2px solid white;
border-top-width: 5px;
}
th {
background-color: black;
color: white;
text-align: right;
vertical-align: bottom;
font-weight: normal;
border-collapse: collapse;
}
td {
background-color: black;
color: yellow;
text-align: left;
vertical-align: bottom;
font-weight: bold;
border-collapse: collapse;
}
</style>
</head>
<body>
<table>
<tr>
<th>Computer Name:</th>
<td><span id=frmCompName></span></td>
</tr>
<tr>
<th>User Name:</th>
<td><span id=frmstrUserName></span></td>
</tr>
<tr>
<th class="tblborderline">OS:</th>
<td class="tblborderline"><span id=frmstrOS></span></td>
</tr>
<tr>
<th>Manufacturer:</th>
<td><span id=frmstrManufacturer></span></td>
</tr>
<tr>
<th>Model:</th>
<td><span id=frmstrModel></span></td>
</tr>
<tr>
<th class="tblborderline">Asset Tag:</th>
<td class="tblborderline"><span id=frmstrAssetTag></span></td>
</tr>
<tr>
<th>CPU Speed:</th>
<td><span id=frmstrCPUSpeed></span></td>
</tr>
<tr>
<th>Memory:</th>
<td><span id=frmintRAMamt></span></td>
</tr>
<tr>
<th>NIC:</th>
<td><span id=frmstrNetworkCard></span></td>
</tr>
<tr>
<th>IP:</th>
<td><span id=frmstrIPAddr></span></td>
</tr>
<tr>
<th class="tblborderline">MAC:</th>
<td class="tblborderline"><span id=frmstrMacAddr></span></td>
</tr>
<tr>
<th>DISK Devices:</h>
<td><select name="DiskDevices"></select></td>
</tr>
<tr>
<th>NET Devices:</th>
<td><select name="NetDevices"></select></td>
</tr>
<tr>
<th>USB Devices:</th>
<td><select name="USBDevices"></select></td>
</tr>
</table>
</body>
</html>
这篇关于HTA 中的 VBS 以提取系统信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文