我正在尝试创建一个管理工具HTA。这比学习更重要。到目前为止,我已经找到了我需要的一切。现在我被困在一块上。我想收集计算机的序列号并将其输出到文本框或文本区域。这是我尝试使用的代码。因为代码将“serialnumber”输出到文本框。任何帮助将不胜感激。
sub ComputerS
set objExec = objShell.Exec("wmic bios get serialnumber")
Set objStdOut = objExec.StdOut
strLine = objStdOut.ReadLine
queryResults.value = strLine
end Sub
这是texarea和按钮的代码
<input type="button" value="Serial" onClick="ComputerS">
<textarea name="queryResults" rows="5" cols="30"></textarea>
所以我明白了。我不得不添加一行代码
sub ComputerS
set objExec = objShell.Exec("wmic bios get serialnumber")
Set objStdOut = objExec.StdOut
objExec.StdOut.skipLine
strLine = objStdOut.ReadLine
queryResults.value = strLine
end Sub
当我添加skipLine时,它工作得很好。 感谢大家的帮助,当我扩展我的工具时,我肯定会在不久的将来使用您的信息。
答案 0 :(得分:2)
试试这个HTA:
<html>
<HTA:APPLICATION
ICON="cmd.exe"
APPLICATIONNAME ="Bios Serial Number"
BORDER="dialog"
BORDERSTYLE="complex"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
>
<Title>Bios Serial Number</title>
<style>
body{
background-color: Black;
}
</style>
<script type="text/Vbscript">
sub ComputerS()
set objShell = CreateObject("wscript.shell")
set objExec = objShell.Exec("wmic bios get serialnumber")
Set objStdOut = objExec.StdOut
strLine = objStdOut.ReadAll
queryResults.value = strLine
end Sub
</script>
<body text="white">
<center>
<textarea name="queryResults" rows="5" cols="30"></textarea><br><br>
<input type="button" value="Get Serial Number" onClick="ComputerS">
</body>
</html>
如果您想获得有关计算机的更多信息,请尝试使用此HTA:
<html>
<HTA:APPLICATION
ICON="cmd.exe"
APPLICATIONNAME ="Get Info PC"
BORDER="dialog"
BORDERSTYLE="complex"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
>
<Title>Get Info PC</title>
<style>
body{
background-color: Black;
}
</style>
<script type="text/Vbscript">
sub ComputerS()
Set oShell = CreateObject("wscript.Shell")
Set env = oShell.environment("Process")
strComputer = env.Item("Computername")
Const HKEY_LOCAL_MACHINE = &H80000002
Const UnInstPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
".\root\default:StdRegProv")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
report = report & "******************************************" & vbCrLf
report = report & " - Information de l'ordinateur " & strComputer & " - " & vbCrLf
report = report & "******************************************" & vbCrLf & vbCrLf
report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Informations sur Windows" & vbCrLf & "******************************************" & vbCrLf
For Each objItem in colItems
report = report & "- Nom du poste: " & strComputer & vbCrLf
report = report & "- Description de l'ordinateur: " & objItem.Description & vbCrLf
report = report & "- Utilisateur possédant la licence Windows: " & objItem.RegisteredUser & vbCrLf
report = report & "- Organisation possédant la licence Windows: " & objItem.Organization & vbCrLf
report = report & "******************************************" & vbCrLf
report = report & "- Nom du système d'exploitation: " & objItem.Caption & vbCrLf
If (objItem.OSProductSuite <> "")Then
report = report & "- Système d'exploitation de la suite " & objItem.OSProductSuite & vbCrLf
End If
report = report & "- Version: " & objItem.Version & vbCrLf
dtmConvertedDate.Value = objItem.InstallDate
dtmInstallDate = dtmConvertedDate.GetVarDate
report = report & "- Date de son installation: " & dtmInstallDate & vbCrLf
report = report & "- Numéro de série de " & objItem.Caption & ": " & objItem.SerialNumber & vbCrLf
report = report & vbCrLf
report = report & "******************************************" & vbCrLf
report = report & "Détails techniques sur Windows"& vbCrlf
report = report & "******************************************" & vbCrLf
report = report & "- Numéro du dernier Service Pack majeur installé: "
report = report & objItem.ServicePackMajorVersion & vbCrLf
If (objItem.MaxNumberOfProcesses="-1") Then
report = report & "- Maximum de processus pouvant être ouvert: Aucune limite fixée" & vbCrLf
Else
report = report & "- Maximum de processus pouvant être ouvert: " & objItem.MaxNumberOfProcesses & vbCrLf
End If
Next
Set colBIOS = objWMIService.ExecQuery _
("Select * from Win32_BIOS")
report = report & "******************************************" & vbCrLf
report = report & "BIOS - Utilitaire de détection des disques et" & vbCrLf
report = report & " de gestion des composantes internes" & vbCrLf & "******************************************" & vbCrLf
For Each objBIOS in colBIOS
report = report & "- Nom: " & objBIOS.Name & vbCrLf
report = report & "- Code d'identification: " & objBIOS.IdentificationCode & vbCrLf
report = report & "- Manufacturier: " & objBIOS.Manufacturer & vbCrLf
report = report & "- BIOS primaire: " & objBIOS.PrimaryBIOS & vbCrLf
dtmConvertedDate.Value = objBIOS.ReleaseDate
dtmInstallDate = dtmConvertedDate.GetVarDate
report = report & "- Date de création: " & dtmInstallDate & vbCrLf
report = report & "- Numéro de série: " & objBIOS.SerialNumber & vbCrLf
report = report & "- Version: " & objBIOS.Version & vbCrLf
report = report & "- Version (SMBIOS): " & objBIOS.SMBIOSBIOSVersion & vbCrLf
report = report & vbCrLf
Next
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
report = report & "******************************************" & vbCrLf
report = report & "Mémoire vive (RAM) et processeur" & vbCrLf & "******************************************" & vbCrLf
For Each objComputer in colSettings
report = report & "- Vous avez actuellement " & objComputer.TotalPhysicalMemory /1024\1024+1 & " Mo de mémoire vive(RAM) au total." & vbcrlf
Next
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_Processor")
For Each objProcessor in colSettings
report = report & "- Type de processeur: "
If objProcessor.Architecture = 0 Then
report = report & "x86" & vbCrLf
ElseIf objProcessor.Architecture = 1 Then
report = report & "MIPS" & vbCrLf
ElseIf objProcessor.Architecture = 2 Then
report = report & "Alpha" & vbCrLf
ElseIf objProcessor.Architecture = 3 Then
report = report & "PowerPC" & vbCrLf
ElseIf objProcessor.Architecture = 6 Then
report = report & "ia64" & vbCrLf
Else
report = report & "inconnu" & vbCrLf
End If
report = report & "- Nom du processeur: " & objProcessor.Name & vbCrLf
report = report & "- Description du processeur: " & objProcessor.Description & vbCrLf
report = report & "- Vitesse actuelle du processeur: " & objProcessor.CurrentClockSpeed & " Mhz" & vbCrLf
report = report & "- Vitesse maximale du processeur: " & objProcessor.MaxClockSpeed & " Mhz" & vbCrLf
report = report & vbCrLf
Next
report = report & "******************************************" & vbCrLf
report = report & "Disque(s) dur(s) et autres lecteurs actuellement " & vbCrLf
report = report & "en usage" & vbCrLf & "******************************************" & vbCrLf
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim oDesLecteurs
Set oDesLecteurs = oFSO.Drives
Dim oUnLecteur
Dim strLectType
For Each oUnLecteur in oDesLecteurs
If oUnLecteur.IsReady Then
Select Case oUnLecteur.DriveType
Case 0: strLectType = "Inconnu"
Case 1: strLectType = "Amovible (Disquette, clé USB, etc.)"
Case 2: strLectType = "Fixe (Disque dur, etc.)"
Case 3: strLectType = "Réseau"
Case 4: strLectType = "CD-Rom"
End Select
report = report & "- Lettre du lecteur: " & oUnLecteur.DriveLetter & vbCrLf
report = report & "- Numéro de série: " & oUnLecteur.SerialNumber & vbCrLf
If (oUnLecteur.FileSystem <> "") Then
report = report & "- Système de fichier utilisé: " & oUnLecteur.FileSystem & vbCrLf
End If
Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='" & oUnLecteur.DriveLetter & ":'")
report = report & "- Il y a " & objLogicalDisk.FreeSpace /1024\1024+1 & " Mo d'espace restant sur ce lecteur/disque" & vbCrLf
report = report & "- Il y a " & objLogicalDisk.Size /1024\1024+1 & " Mo d'espace au total sur ce lecteur/disque" & vbCrLf
End If
report = report & vbCrLf
Next
queryResults.value = report
end Sub
</script>
<body text="white">
<center>
<textarea name="queryResults" rows="35" cols="120"></textarea><br><br>
<input type="button" value="Get Info PC" onClick="ComputerS">
</body>
</html>
答案 1 :(得分:0)
所以我最终找到了我自己寻找的答案。我正在寻找的代码非常简单。
objExec.StdOut.SkipLine
这是我需要添加以获得我想要的结果的唯一内容。