-
VBS and HTA help please
Hi
I have been trying to merge 2 scripts I found out on the interned. I am new to scripting and have completed some online tutorials but continue to have problems with the project i am trying to accomplish.
The script works as is but i am trying to consolidate the scripts to output the results on the screen and to XML. I have invested a week and cant figure it out, Please help.
<head>
<hta:application
applicationname="PCinfoTool"
>
<script language="VBScript">
Option Explicit
Private objWMIService
Private strComputer
Function HTMLEncode(strValue)
HTMLEncode= REplace(Replace(strValue,"<","<"),">",">")
End Function
' Main procedure used to generate report. Calls other procedures that generate the HTML for each section
Sub GenerateReport
if strComputer = "" Then
Dim objNetwork
set objNetwork = createobject("wscript.network")
strComputer = objNetwork.ComputerName
End If
Dim objSWbemLocator
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
OS.InnerHTML = OS_HTML
End Sub
' Returns a HTML report for the "Operating System" section
Function OS_HTML()
Dim objItem, colItems
Dim strHTML
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objItem In colItems
Dim strCaption
Dim intServicePackMajor,intServicePackMinor,intTotalVisibleMemorySize
On Error Resume Next
strCaption = HTMLEncode(objItem.Caption)
intServicePackMajor = objItem.ServicePackMajorVersion
intServicePackMinor = objItem.ServicePackMinorVersion
strHTML = strHTML & "<table class=""Table"">" & _
"<tr>" & _
"<th>Operating System:</th><td>" & strCaption & "</td>" & _
"<tr>" & _
"<th>Service Pack:</th><td>" & intServicePackMajor & "</td>" & _
"</table>"
Next
OS_HTML = strHTML
End Function
</script>
<script language="VBScript">
sub mainone
results = results & "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "?>" & vbcrlf
results = results & "<Inventory>" & vbcrlf
if OS_Info.checked then
results = results & "<PC_info>" & vbcrlf
' Get Local Login Information
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
results = results & "<Domain>" & objItem.Domain & "</Domain>" & vbcrlf
results2 = results2 & "Domain :" & objItem.Domain & "<BR>"
Next
results = results & "</PC_info>" & vbcrlf
end if
results = results & "</Inventory>" & vbcrlf
DataArea.InnerHTML = results2
if xml_Info.checked then output(results)
end sub
Sub Output(myxml)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("Output.xml", true)
objFile.Write myxml
objFile.Close
End Sub
</script>
</head>
<body OnLoad="GenerateReport">
<div id="Main" style="display:none;"></div>
<div id="OS" class="InfoSectionBody" ></div>
<hr>
<hr>
<input type="checkbox" name="OS_Info" id="OS_Info"> Domain
<input type="checkbox" name="xml_Info" id="xml_Info"> output to xml?
<input type="button" value="RUN XML" name="run_button" onClick="mainone" />
<p><span id=DataArea>Output will be saved to Output.xml</span></p>
</body>
</html>
-
Re: VBS and HTA help please
Figured out my problem
thanks
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Page generated in 1,714,036,714.74428 seconds with 16 queries
Bookmarks