Vbscript 计算机信息脚本

Vbscript 计算机信息脚本,vbscript,wmi,Vbscript,Wmi,有人能帮我修改一下吗 与开始时出现的询问计算机ID/名称的对话框不同,是否有自动输入的对话框,因此它是全自动的?最后,不是打开文件,而是将其存储在硬盘上(与脚本的目录相同) 出错时继续下一步 Const HKEY_当前用户=&H80000001 Const HKEY_本地_机器=&H8000002 Dim结构计算机、对象管理器、propValue、对象管理器 Dim strUserName、strPassword、colItems、SWBemlocator '此部分查询要扫描的工作站。 strC

有人能帮我修改一下吗

与开始时出现的询问计算机ID/名称的对话框不同,是否有自动输入的对话框,因此它是全自动的?最后,不是打开文件,而是将其存储在硬盘上(与脚本的目录相同)

出错时继续下一步
Const HKEY_当前用户=&H80000001
Const HKEY_本地_机器=&H8000002
Dim结构计算机、对象管理器、propValue、对象管理器
Dim strUserName、strPassword、colItems、SWBemlocator
'此部分查询要扫描的工作站。
strComputer=输入框(“工作站”,“输入要扫描的工作站ID。”,“)
UserName=“”
Password=“”
ImgDir=“C:\Scripts\images\”
'设置要在整个脚本中使用的连接和对象。
设置SWBemlocator=CreateObject(“WbemScripting.SWBemlocator”)
设置objWMIService=SWBemlocator.ConnectServer(strComputer,“root\CIMV2”,strUserName,strPassword)
'这将确定正在扫描的电脑的当前日期和时间。
Set colItems=objWMIService.ExecQuery(“从Win32_LocalTime中选择*,”WQL“,wbemFlagReturn立即+wbemFlagForwardOnly)
对于每个对象,在colitem中
如果objItem.Minute<10,则
theMinutes=“0”和objItem.Minute
其他的
分钟=objItem.Minute
如果结束
如果objItem.Second小于10,则
theSeconds=“0”和objItem.Second
其他的
秒=对象秒
如果结束
DateTime=objItem.Month&“/”&objItem.Day&“/”&objItem.Year&“-”&objItem.Hour&“:”&theMinutes&“:”&theSeconds
下一个
'获取有关操作系统的一些信息,包括service pack级别。
Set colItems=objWMIService.ExecQuery(“从Win32\u操作系统中选择*”,48)
对于每个对象,在colitem中
WKID=objItem.CSName
WKOS=objItem.Caption
ServicePack=objItem.ServicePackMajorVersion&“&objItem.ServicePackMinorVersion
下一个
'此部分返回视频卡和当前分辨率。
Set colItems=objWMIService.ExecQuery(“从Win32\u DisplayConfiguration中选择*,,48)
对于每个对象,在colitem中
视频卡=objItem.DeviceName
分辨率=objItem.PelsWidth&“x”&objItem.PelsHeight&“x”&objItem.BitsPerPel&“bits”
下一个
'此部分返回视频卡内存。
设置objWMIService=GetObject(“winmgmts:\\”&strComputer&“\root\cimv2”)
设置colItems=objWMIService.ExecQuery(“从Win32\u VideoController中选择*)
对于每个对象,在colitem中
VideoMemory=objItem.AdapterRAM/1024/1024
下一个
'返回各种系统信息,包括当前登录的用户、域、内存、制造商和型号。
Set colItems=objWMIService.ExecQuery(“从Win32\u ComputerSystem中选择*”,48)
对于每个对象,在colitem中
UserName=objItem.UserName
Domain=objItem.Domain
TotalMemory=int((objItem.TotalPhysicalMemory/1024)/1024+1)
制造商=objItem.Manufacturer
Model=objItem.Model
下一个
'这决定了总硬盘空间和可用硬盘空间。
Set colItems=objWMIService.ExecQuery(“从Win32中选择*,其中Name='C:'”,.48)
对于每个对象,在colitem中
FreeHDSpace=Fix((objItem.FreeSpace/1024)/1024)/1024)
TotalHDSpace=Fix((objItem.Size/1024)/1024)/1024)
下一个
'此部分返回默认打印机和打印机端口。
设置colItems=objWMIService.ExecQuery(“从Win32_打印机中选择*,其中默认值为True”,“WQL”,wbemFlagReturn立即+wbemFlagForwardOnly”)
对于每个对象,在colitem中
Printer=objItem.Name
PortName=objItem.PortName
下一个
'这将返回CPU信息。
Set colItems=objWMIService.ExecQuery(“从Win32_处理器中选择*”、“WQL”、WBEMFlagReturn立即+wbemFlagForwardOnly)
对于每个对象,在colitem中
CPUDesc=LTrim(objItem.Name)
下一个
'这将返回系统的当前正常运行时间(自上次重新启动以来的时间)。
设置colOperatingSystems=objWMIService.ExecQuery(“从Win32\U OperatingSystem中选择*)
对于协同操作系统中的每个OBJO
dtmBootup=objOS.LastBootUpTime
dtmLastBootupTime=WMIDateStringToDate(dtmBootup)
dtmsystemoptime=DateDiff(“h”,dtmLastBootUpTime,Now)
正常运行时间=dtmSystemUptime
下一个
函数WMIDateStringToDate(dtmBootup)
WMIDateStringToDate=CDate(Mid(dtmBootup,5,2)&“/”&Mid(dtmBootup,7,2)&“/”&Left(dtmBootup,4)&“&Mid(dtmBootup,9,2)&”:“&Mid(dtmBootup,11,2)&“&Mid(dtmBootup,13,2))
端函数
'这将设置Internet Explorer窗口以显示结果。
设置objExplorer=WScript.CreateObject(“InternetExplorer.Application”、“IE_”)
使用objExplorer
.导航“关于:空白”
.Toolbar=0
.StatusBar=0
.宽度=800
.高度=600
.左=75
.Top=0
.Visible=1
以
设置fileOutput=objExplorer.Document
'这是要显示的网页的代码。
文件输出。打开
fileOutput.WriteLn“”
fileOutput.WriteLn“”
fileOutput.WriteLn“WKID&”的系统信息
fileOutput.WriteLn“”
fileOutput.WriteLn“”
fileOutput.WriteLn“”
fileOutput.WriteLn“WKID&”的工作台/服务器信息
fileOutput.WriteLn“”
fileOutput.WriteLn“”
fileOutput.WriteLn“”
fileOutput.WriteLn“”
fileOutput.WriteLn“”
fileOutput.WriteLn“”
fileOutput.WriteLn“”
fileOutput.WriteLn“WKInfo-工作站的一般信息。”
fileOutput.WriteLn“”
fileOutput.WriteLn“”
fileOutput.WriteLn“”
fileOutput.WriteLn“上次扫描”
fileOutput.WriteLn“日期/时间”&DateTime&“
fileOutput.WriteLn“系统正常运行时间”&正常运行时间和“小时”
fileOutput.WriteLn“
On Error Resume Next
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Dim strComputer, objWMIService, propValue, objItem
Dim strUserName, strPassword, colItems, SWBemlocator

' This section queries for the workstation to be scanned.
strComputer = inputbox ("Workstation", "Enter the workstation ID to scan.",".")
UserName = ""
Password = ""
ImgDir = "C:\Scripts\images\"

'Sets up the connections and objects to be used throughout the script.
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",strUserName,strPassword)

'This determines the current date and time of the PC being scanned.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LocalTime", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    If objItem.Minute < 10 Then
        theMinutes = "0" & objItem.Minute
    Else
        theMinutes = objItem.Minute
    End If
    If objItem.Second < 10 Then
        theSeconds = "0" & objItem.Second
    Else
        theSeconds = objItem.Second
    End If
    DateTime = objItem.Month & "/" & objItem.Day & "/" & objItem.Year & " - " & objItem.Hour & ":" & theMinutes & ":" & theSeconds
Next

'Gets some information about the operating system including service pack level.
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
    WKID = objItem.CSName
    WKOS = objItem.Caption
    ServicePack = objItem.ServicePackMajorVersion & "." & objItem.ServicePackMinorVersion
Next

'This section returns the Video card and current resolution.
Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayConfiguration",,48)
For Each objItem in colItems
    VideoCard = objItem.DeviceName
    Resolution = objItem.PelsWidth & " x " & objItem.PelsHeight & " x " & objItem.BitsPerPel & " bits"
Next

'This section returns the Video card memory.
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_VideoController")
For Each objItem in colItems
    VideoMemory = objItem.AdapterRAM/1024/1024
Next

'This returns various system information including current logged on user, domain, memory, manufacture and model.
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
    UserName = objItem.UserName
    Domain = objItem.Domain
    TotalMemory = int((objItem.TotalPhysicalMemory/1024)/1024+1)
    Manufacturer = objItem.Manufacturer
    Model = objItem.Model
Next

'This determines the total hard drive space and free hard drive space.
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where Name='C:'",,48)
For Each objItem in colItems
    FreeHDSpace = Fix(((objItem.FreeSpace/1024)/1024)/1024)
    TotalHDSpace = Fix(((objItem.Size/1024)/1024)/1024)
Next

'This section returns the default printer and printer port.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Printer where Default=True", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    Printer = objItem.Name
    PortName = objItem.PortName
Next

'This returns the CPU information.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    CPUDesc = LTrim(objItem.Name)
Next

'This returns the current uptime (time since last reboot) of the system.
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOS in colOperatingSystems
    dtmBootup = objOS.LastBootUpTime
    dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
    dtmSystemUptime = DateDiff("h", dtmLastBootUpTime, Now)
    Uptime = dtmSystemUptime
Next
Function WMIDateStringToDate(dtmBootup)
    WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) & " " & Mid (dtmBootup, 9, 2) & ":" & Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))
End Function

'This sets up the Internet Explorer window in order to show the results.
Set objExplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")
With objExplorer
    .Navigate "about:Blank"
    .Toolbar = 0
    .StatusBar = 0
    .Width = 800
    .Height = 600
    .Left = 75
    .Top = 0
    .Visible = 1
End With
Set fileOutput = objExplorer.Document

'This is the code for the web page to be displayed.
fileOutput.Open
fileOutput.WriteLn "<html>"
fileOutput.WriteLn "    <head>"
fileOutput.WriteLn "        <title>System Information for '" & WKID & "' </title>"
fileOutput.WriteLn "    </head>"
fileOutput.WriteLn "    <body bgcolor='#FFFFFF' text='#000000' link='#0000FF' vlink='000099' alink='#00FF00'>"
fileOutput.WriteLn "        <center>"
fileOutput.WriteLn "            <h3>Workstaion/Server Information for " & WKID & "</h3>"
fileOutput.WriteLn "            <table border='0' cellspacing='1' cellpadding='1' width='95%'>"
fileOutput.WriteLn "                <tr><td background='" & ImgDir & "blue_spacer.gif'>"
fileOutput.WriteLn "                    <table border='0' cellspacing='0' cellpadding='0' width='100%'>"
fileOutput.WriteLn "                        <tr><td>"
fileOutput.WriteLn "                            <table border='0' cellspacing='0' cellpadding='0' width='100%'>"
fileOutput.WriteLn "                                <tr>"
fileOutput.WriteLn "                                    <td width='5%' align='left' valign='middle' background='" & ImgDir & "blue_spacer.gif'><img src='" & ImgDir & "write.gif'></td>"
fileOutput.WriteLn "                                    <td width='95%' align='left' valign='middle' background='" & ImgDir & "blue_spacer.gif'> <font color='#FFFFFF' size='5'>WKInfo - </font><font color='#FFFFFF' size='3'>General information on the Workstation.</font></td>"
fileOutput.WriteLn "                                </tr>"
fileOutput.WriteLn "                                <tr><td colspan='2' bgcolor='#FFFFFF'>"
fileOutput.WriteLn "                                    <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Last Scanned</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Date/Time</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & DateTime & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>System Uptime</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Uptime & " hours</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Workstation ID</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & WKID & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Domain</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Domain & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>UserName</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & UserName & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General OS Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Operating System</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & WKOS & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Service Pack</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & ServicePack & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Computer Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Manufacturer</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Manufacturer & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Model</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Model & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Hardware Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>CPU</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & CPUDesc & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Memory</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & TotalMemory & " MB</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Total HD Space</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & TotalHDSpace & " GB</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Free HD Space</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & FreeHDSpace & " GB</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Video Card Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Video Card</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & VideoCard & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Resolution</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Resolution & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Memory</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & VideoMemory & " MB</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Default Printer Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Printer</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Printer & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Port Name</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & PortName & "</i></td></tr>"
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Shared Directories</i></b></TD></TR>"
'This sextion lists all the current shares enabled on the PC.
fileOutput.WriteLn "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.WriteLn "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLn "                                                <TR><TD width='30%' align='center' bgcolor='#e0e0e0'><b>Name</b></td><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Path</b><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Description</b></td><tr>"
Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")
For each objShare in colShares
    fileOutput.WriteLn "                                                <TR><TD width='30%' align='left' bgcolor='#f0f0f0'><i>" & objShare.Name & "</i></TD><td bgcolor=#f0f0f0 align=left><i>" & objShare.Path & "</i></TD><td bgcolor=#f0f0f0 align=left><i>" & objShare.Caption & "</i></td></tr>"
Next
fileOutput.WriteLn "                                            </table>"
fileOutput.WriteLn "                                        </td></tr>"
'This section lists all the current services and their status.
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Current Service Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.WriteLn "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLn "                                                <TR><TD width='70%' align='center' bgcolor='#e0e0e0'><b>Service Name</b></td><TD width='30%' align='center' bgcolor='#e0e0e0'><b>Service State</b></td><tr>"
Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objService in colRunningServices
fileOutput.WriteLn "                                            <TR><TD align='left' bgcolor='#f0f0f0'>" & objService.DisplayName & "</TD><td bgcolor=#f0f0f0 align=center><i>" & objService.State & "</i></td></tr>"
Next
fileOutput.WriteLn "                                            </table>"
fileOutput.WriteLn "                                        </td></tr>"
'This section lists all the current running processes and some information.
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Current Process Information</i></b></TD></TR>"
fileOutput.WriteLn "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.WriteLn "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLn "                                                <TR><TD width='10%' align='center' bgcolor='#e0e0e0'><b>PID</b></td><TD width='35%' align='center' bgcolor='#e0e0e0'><b>Process Name</b></td><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Owner</b></td><TD width='15%' align='center' bgcolor='#e0e0e0'><b>Memory</b></td></tr>"
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process")
For Each objProcess in colProcessList
colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)
fileOutput.WriteLn "                                                <TR><TD align='center' bgcolor='#f0f0f0'>" & objProcess.Handle & "</td><TD align='center' bgcolor='#f0f0f0'>" & objProcess.Name & "</td><TD align='center' bgcolor='#f0f0f0'>" & strUserDomain & "\" & strNameOfUser & "</td><TD align='center' bgcolor='#f0f0f0'>" & objProcess.WorkingSetSize/1024 & " kb</td><tr>"
Next
fileOutput.WriteLn "                                            </table>"
fileOutput.WriteLn "                                        </td></tr>"
'This section lists all the currently installed software on the machine.
fileOutput.WriteLn "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Installed Software</i></b></TD></TR>"
fileOutput.WriteLn "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")
For Each objSoftware in colSoftware
    fileOutput.WriteLn"                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
    fileOutput.WriteLn"                                                <tr><td align=left bgcolor='#e0e0e0'><b>Caption:</b></td><td colspan=2 bgcolor=#f0f0f0>" & objSoftware.Caption & "</td></tr>"
    fileOutput.WriteLn"                                                <tr><td align=left bgcolor='#e0e0e0'><b>Install Location:</b></td><td colspan=2 bgcolor=#f0f0f0>" & objSoftware.InstallLocation & "</td></tr>"
    fileOutput.WriteLn"                                                <tr><td width=30% align=center bgcolor='#e0e0e0'><b>Name</b></td><td width=30% align=center bgcolor='#e0e0e0'><b>Vendor</b></td><td width=30% align=center bgcolor='#e0e0e0'><b>Version</b></td></tr>"
    fileOutput.WriteLn"                                                <tr><td align=center bgcolor=#f0f0f0>" & objSoftware.Name & "</td><td align=center bgcolor=#f0f0f0>" & objSoftware.Vendor & "</td><td align=center bgcolor=#f0f0f0>" & objSoftware.Version & "</td></tr>"
    fileOutput.WriteLn"                                                <tr height=2><td height=10 align=center bgcolor=midnightblue colspan=3></td></tr>"
    fileOutput.WriteLn"                                            </table>"
Next
fileOutput.WriteLn "                                        </td></tr>"
fileOutput.WriteLn "                                    </table>"
fileOutput.WriteLn "                                </td></tr>"
fileOutput.WriteLn "                            </table>"
fileOutput.WriteLn "                        </td></tr>"
fileOutput.WriteLn "                    </table>"
fileOutput.WriteLn "                </td></tr>"
fileOutput.WriteLn "            </table>"
fileOutput.WriteLn "            <p><small></small></p>"
fileOutput.WriteLn "        </center>"
fileOutput.WriteLn "    </body>"
fileOutput.WriteLn "<html>"
fileOutput.close
WScript.Quit 
Set objWMIService = SWBemlocator.ConnectServer( ,"root\CIMV2",strUserName,strPassword)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
On Error Resume Next
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Dim strComputer, objWMIService, propValue, objItem
Dim strUserName, strPassword, colItems, SWBemlocator

' This section queries for the workstation to be scanned.
strComputer = "." ' . = local computer, you can substitute it by name, or ip
strComputer = "REMOTEPC" ' example of a remote pc by computername
strComputer = "127.0.0.1" ' local computer pulled up via ip
UserName = ""
Password = ""
ImgDir = "C:\Scripts\images\"

'Sets up the connections and objects to be used throughout the script.
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",strUserName,strPassword)

'This determines the current date and time of the PC being scanned.
Dim DateTime
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LocalTime", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    If objItem.Minute < 10 Then
        theMinutes = "0" & objItem.Minute
    Else
        theMinutes = objItem.Minute
    End If
    If objItem.Second < 10 Then
        theSeconds = "0" & objItem.Second
    Else
        theSeconds = objItem.Second
    End If
    DateTime = objItem.Month & "/" & objItem.Day & "/" & objItem.Year & " - " & objItem.Hour & ":" & theMinutes & ":" & theSeconds
Next

Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("MyFile.log", True)
MyFile.WriteLine(strComputer & " -> " & DateTime)
MyFile.Close

If Err.Number <> 0 Then
  WScript.Echo Err.Description
End if
' This section queries for the workstation to be scanned.
strComputer = inputbox ("Workstation", "Enter the workstation ID to scan.",".")
UserName = ""
Password = ""
ImgDir = "C:\Scripts\images\"
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Dim strComputer, objWMIService, propValue, objItem
Dim strUserName, strPassword, colItems, SWBemlocator

' This section queries for the workstation to be scanned.
UserName = ""
Password = ""
strComputer = "127.1.1.1"
ImgDir = "C:\Scripts\images\"

'Sets up the connections and opjects to be used throughout the script.
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(,"root\CIMV2",strUserName,strPassword)

'This determines the current date and time of the PC being scanned.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LocalTime", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    If objItem.Minute < 10 Then
        theMinutes = "0" & objItem.Minute
    Else
        theMinutes = objItem.Minute
    End If
    If objItem.Second < 10 Then
        theSeconds = "0" & objItem.Second
    Else
        theSeconds = objItem.Second
    End If
    DateTime = objItem.Month & "/" & objItem.Day & "/" & objItem.Year & " - " & objItem.Hour & ":" & theMinutes & ":" & theSeconds
Next

'Gets some ingomation about the Operating System including Service Pack level.
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
    WKID = objItem.CSName
    WKOS = objItem.Caption
    ServicePack = objItem.ServicePackMajorVersion & "." & objItem.ServicePackMinorVersion
Next

'This section returns the Video card and current resolution.
Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayConfiguration",,48)
For Each objItem in colItems
    VideoCard = objItem.DeviceName
    Resolution = objItem.PelsWidth & " x " & objItem.PelsHeight & " x " & objItem.BitsPerPel & " bits"
Next

'This section returns the Video card memory.
Set objWMIService = GetObject("winmgmts:root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_VideoController")
For Each objItem in colItems
    VideoMemory = objItem.AdapterRAM/1024/1024
Next

'This returns various system information including current logged on user, domain, memory, manufacture and model.
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
    UserName = objItem.UserName
    Domain = objItem.Domain
    TotalMemory = int((objItem.TotalPhysicalMemory/1024)/1024+1)
    Manufacturer = objItem.Manufacturer
    Model = objItem.Model
Next

'This determines the total hard drive space and free hard drive space.
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where Name='C:'",,48)
For Each objItem in colItems
    FreeHDSpace = Fix(((objItem.FreeSpace/1024)/1024)/1024)
    TotalHDSpace = Fix(((objItem.Size/1024)/1024)/1024)
Next

'This section returns the default printer and printer port.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Printer where Default=True", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    Printer = objItem.Name
    PortName = objItem.PortName
Next

'This returns the CPU information.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    CPUDesc = LTrim(objItem.Name)
Next

'This returns the current uptime (time since last reboot) of the system.
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOS in colOperatingSystems
    dtmBootup = objOS.LastBootUpTime
    dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
    dtmSystemUptime = DateDiff("h", dtmLastBootUpTime, Now)
    Uptime = dtmSystemUptime
Next
Function WMIDateStringToDate(dtmBootup)
    WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) & " " & Mid (dtmBootup, 9, 2) & ":" & Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))
End Function

dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

' -- The heart of the create file script -----------------------
' -- Creates the file using the value of strFile on Line 11
' --------------------------------------------------------------
Set fileOutput = objFSO.CreateTextFile( "x.html", true )

'Set fileOutput = objExplorer.Document

'This is the code for the web page to be displayed.

fileOutput.WriteLine "<html>"
fileOutput.WriteLine "    <head>"
fileOutput.WriteLine "        <title>System Information for '" & WKID & "' </title>"
fileOutput.WriteLine "    </head>"
fileOutput.WriteLine "    <body bgcolor='#FFFFFF' text='#000000' link='#0000FF' vlink='000099' alink='#00FF00'>"
fileOutput.WriteLine "        <center>"
fileOutput.WriteLine "            <h3>Workstaion/Server Information for " & WKID & "</h3>"
fileOutput.WriteLine "            <table border='0' cellspacing='1' cellpadding='1' width='95%'>"
fileOutput.WriteLine "                <tr><td background='" & ImgDir & "blue_spacer.gif'>"
fileOutput.WriteLine "                    <table border='0' cellspacing='0' cellpadding='0' width='100%'>"
fileOutput.WriteLine "                        <tr><td>"
fileOutput.WriteLine "                            <table border='0' cellspacing='0' cellpadding='0' width='100%'>"
fileOutput.WriteLine "                                <tr>"
fileOutput.WriteLine "                                    <td width='5%' align='left' valign='middle' background='" & ImgDir & "blue_spacer.gif'><img src='" & ImgDir & "write.gif'></td>"
fileOutput.WriteLine "                                    <td width='95%' align='left' valign='middle' background='" & ImgDir & "blue_spacer.gif'> <font color='#FFFFFF' size='5'>WKInfo - </font><font color='#FFFFFF' size='3'>General information on the Workstation.</font></td>"
fileOutput.WriteLine "                                </tr>"
fileOutput.WriteLine "                                <tr><td colspan='2' bgcolor='#FFFFFF'>"
fileOutput.WriteLine "                                    <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLine "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Last Scanned</i></b></TD></TR>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Date/Time</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & DateTime & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>System Uptime</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Uptime & " hours</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Information</i></b></TD></TR>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Workstation ID</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & WKID & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Domain</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Domain & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>UserName</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & UserName & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General OS Information</i></b></TD></TR>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Operating System</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & WKOS & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Service Pack</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & ServicePack & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Computer Information</i></b></TD></TR>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Manufacturer</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Manufacturer & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Model</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Model & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Hardware Information</i></b></TD></TR>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>CPU</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & CPUDesc & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Memory</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & TotalMemory & " MB</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Total HD Space</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & TotalHDSpace & " GB</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Free HD Space</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & FreeHDSpace & " GB</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Video Card Information</i></b></TD></TR>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Video Card</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & VideoCard & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Resolution</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Resolution & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Memory</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & VideoMemory & " MB</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Default Printer Information</i></b></TD></TR>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Printer</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Printer & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Port Name</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & PortName & "</i></td></tr>"
fileOutput.WriteLine "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Shared Directories</i></b></TD></TR>"
'This sextion lists all the current shares enabled on the PC.
fileOutput.WriteLine "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.WriteLine "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLine "                                                <TR><TD width='30%' align='center' bgcolor='#e0e0e0'><b>Name</b></td><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Path</b><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Description</b></td><tr>"
Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")
For each objShare in colShares
    fileOutput.WriteLine "                                                <TR><TD width='30%' align='left' bgcolor='#f0f0f0'><i>" & objShare.Name & "</i></TD><td bgcolor=#f0f0f0 align=left><i>" & objShare.Path & "</i></TD><td bgcolor=#f0f0f0 align=left><i>" & objShare.Caption & "</i></td></tr>"
Next
fileOutput.WriteLine "                                            </table>"
fileOutput.WriteLine "                                        </td></tr>"
'This section lists all the current services and their status.
fileOutput.WriteLine "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Current Service Information</i></b></TD></TR>"
fileOutput.WriteLine "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.WriteLine "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLine "                                                <TR><TD width='70%' align='center' bgcolor='#e0e0e0'><b>Service Name</b></td><TD width='30%' align='center' bgcolor='#e0e0e0'><b>Service State</b></td><tr>"
Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objService in colRunningServices
fileOutput.WriteLine "                                            <TR><TD align='left' bgcolor='#f0f0f0'>" & objService.DisplayName & "</TD><td bgcolor=#f0f0f0 align=center><i>" & objService.State & "</i></td></tr>"
    wscript.echo  "                                            <TR><TD align='left' bgcolor='#f0f0f0'>" & objService.DisplayName & "</TD><td bgcolor=#f0f0f0 align=center><i>" & objService.State & "</i></td></tr>"
Next
fileOutput.WriteLine "                                            </table>"
fileOutput.WriteLine "                                        </td></tr>"
'This section lists all the current running processes and some information.
fileOutput.WriteLine "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Current Process Information</i></b></TD></TR>"
fileOutput.WriteLine "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.WriteLine "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.WriteLine "                                                <TR><TD width='10%' align='center' bgcolor='#e0e0e0'><b>PID</b></td><TD width='35%' align='center' bgcolor='#e0e0e0'><b>Process Name</b></td><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Owner</b></td><TD width='15%' align='center' bgcolor='#e0e0e0'><b>Memory</b></td></tr>"
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process")
For Each objProcess in colProcessList
colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)
fileOutput.WriteLine "                                                <TR><TD align='center' bgcolor='#f0f0f0'>" & objProcess.Handle & "</td><TD align='center' bgcolor='#f0f0f0'>" & objProcess.Name & "</td><TD align='center' bgcolor='#f0f0f0'>" & strUserDomain & "\" & strNameOfUser & "</td><TD align='center' bgcolor='#f0f0f0'>" & objProcess.WorkingSetSize/1024 & " kb</td><tr>"
Next
fileOutput.WriteLine "                                            </table>"
fileOutput.WriteLine "                                        </td></tr>"
'This section lists all the currently installed software on the machine.
fileOutput.WriteLine "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Installed Software</i></b></TD></TR>"
fileOutput.WriteLine "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")
For Each objSoftware in colSoftware
    fileOutput.WriteLine"                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
    fileOutput.WriteLine"                                                <tr><td align=left bgcolor='#e0e0e0'><b>Caption:</b></td><td colspan=2 bgcolor=#f0f0f0>" & objSoftware.Caption & "</td></tr>"
    fileOutput.WriteLine"                                                <tr><td align=left bgcolor='#e0e0e0'><b>Install Location:</b></td><td colspan=2 bgcolor=#f0f0f0>" & objSoftware.InstallLocation & "</td></tr>"
    fileOutput.WriteLine"                                                <tr><td width=30% align=center bgcolor='#e0e0e0'><b>Name</b></td><td width=30% align=center bgcolor='#e0e0e0'><b>Vendor</b></td><td width=30% align=center bgcolor='#e0e0e0'><b>Version</b></td></tr>"
    fileOutput.WriteLine"                                                <tr><td align=center bgcolor=#f0f0f0>" & objSoftware.Name & "</td><td align=center bgcolor=#f0f0f0>" & objSoftware.Vendor & "</td><td align=center bgcolor=#f0f0f0>" & objSoftware.Version & "</td></tr>"
    fileOutput.WriteLine"                                                <tr height=2><td height=10 align=center bgcolor=midnightblue colspan=3></td></tr>"
    fileOutput.WriteLine"                                            </table>"
Next
fileOutput.WriteLine "                                        </td></tr>"
fileOutput.WriteLine "                                    </table>"
fileOutput.WriteLine "                                </td></tr>"
fileOutput.WriteLine "                            </table>"
fileOutput.WriteLine "                        </td></tr>"
fileOutput.WriteLine "                    </table>"
fileOutput.WriteLine "                </td></tr>"
fileOutput.WriteLine "            </table>"
fileOutput.WriteLine "            <p><small></small></p>"
fileOutput.WriteLine "        </center>"
fileOutput.WriteLine "    </body>"
fileOutput.WriteLine "<html>"
fileOutput.close
WScript.Quit
On Error Resume Next
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Dim strComputer, objWMIService, propValue, objItem
Dim strUserName, strPassword, colItems, SWBemlocator

ImgDir = "C:\Scripts\images\"

' *******************************************************************
' This section gets workstation name, username and password from the command prompt.
Set objArgs = WScript.Arguments

If objArgs.Count = 1 then
    strComputer = objArgs(0)
    UserName = ""
    Password = ""
ElseIf objArgs.Count = 3 then
    strComputer = objArgs(0)
    UserName = objArgs(1)
    Password = objArgs(2)
Else
    wscript.echo "SYNTAX:  cscript scan.vbs [machinename] [username] [password]"
    wscript.echo "Parameter: Machinename - required"
    wscript.echo "Parameter: username - optional"
    wscript.echo "Parameter: password- required if username provided."
    wscript.quit
End If
' *******************************************************************

'Sets up the connections and opjects to be used throughout the script.
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",strUserName,strPassword)

'This determines the current date and time of the PC being scanned.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LocalTime", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    If objItem.Minute < 10 Then
        theMinutes = "0" & objItem.Minute
    Else
        theMinutes = objItem.Minute
    End If
    If objItem.Second < 10 Then
        theSeconds = "0" & objItem.Second
    Else
        theSeconds = objItem.Second
    End If
    DateTime = objItem.Month & "/" & objItem.Day & "/" & objItem.Year & " - " & objItem.Hour & ":" & theMinutes & ":" & theSeconds
Next

'Gets some ingomation about the Operating System including Service Pack level.
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
    WKID = objItem.CSName
    WKOS = objItem.Caption
    ServicePack = objItem.ServicePackMajorVersion & "." & objItem.ServicePackMinorVersion
Next

'This section returns the Video card and current resolution.
Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayConfiguration",,48)
For Each objItem in colItems
    VideoCard = objItem.DeviceName
    Resolution = objItem.PelsWidth & " x " & objItem.PelsHeight & " x " & objItem.BitsPerPel & " bits"
Next

'This section returns the Video card memory.
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_VideoController")
For Each objItem in colItems
    VideoMemory = objItem.AdapterRAM/1024/1024
Next

'This returns various system information including current logged on user, domain, memory, manufacture and model.
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
    UserName = objItem.UserName
    Domain = objItem.Domain
    TotalMemory = int((objItem.TotalPhysicalMemory/1024)/1024+1)
    Manufacturer = objItem.Manufacturer
    Model = objItem.Model
Next

'This determines the total hard drive space and free hard drive space.
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where Name='C:'",,48)
For Each objItem in colItems
    FreeHDSpace = Fix(((objItem.FreeSpace/1024)/1024)/1024)
    TotalHDSpace = Fix(((objItem.Size/1024)/1024)/1024)
Next

'This section returns the default printer and printer port.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Printer where Default=True", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    Printer = objItem.Name
    PortName = objItem.PortName
Next

'This returns the CPU information.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
    CPUDesc = LTrim(objItem.Name)
Next

'This returns the current uptime (time since last reboot) of the system.
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOS in colOperatingSystems
    dtmBootup = objOS.LastBootUpTime
    dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
    dtmSystemUptime = DateDiff("h", dtmLastBootUpTime, Now)
    Uptime = dtmSystemUptime
Next
Function WMIDateStringToDate(dtmBootup)
    WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) & " " & Mid (dtmBootup, 9, 2) & ":" & Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))
End Function

' *******************************************************************
Const TristateFalse = 0
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fileOutput = objFSO.OpenTextFile("c:\scan_results\" & strComputer & ".html", ForWriting, True, TristateFalse)
' *******************************************************************

'This is the code for the web page to be displayed.
fileOutput.writeline "<html>"
fileOutput.writeline "    <head>"
fileOutput.writeline "        <title>System Information for '" & WKID & "' </title>"
fileOutput.writeline "    </head>"
fileOutput.writeline "    <body bgcolor='#FFFFFF' text='#000000' link='#0000FF' vlink='000099' alink='#00FF00'>"
fileOutput.writeline "        <center>"
fileOutput.writeline "            <h3>Workstaion/Server Information for " & WKID & "</h3>"
fileOutput.writeline "            <table border='0' cellspacing='1' cellpadding='1' width='95%'>"
fileOutput.writeline "                <tr><td background='" & ImgDir & "blue_spacer.gif'>"
fileOutput.writeline "                    <table border='0' cellspacing='0' cellpadding='0' width='100%'>"
fileOutput.writeline "                        <tr><td>"
fileOutput.writeline "                            <table border='0' cellspacing='0' cellpadding='0' width='100%'>"
fileOutput.writeline "                                <tr>"
fileOutput.writeline "                                    <td width='5%' align='left' valign='middle' background='" & ImgDir & "blue_spacer.gif'><img src='" & ImgDir & "write.gif'></td>"
fileOutput.writeline "                                    <td width='95%' align='left' valign='middle' background='" & ImgDir & "blue_spacer.gif'> <font color='#FFFFFF' size='5'>WKInfo - </font><font color='#FFFFFF' size='3'>General information on the Workstation.</font></td>"
fileOutput.writeline "                                </tr>"
fileOutput.writeline "                                <tr><td colspan='2' bgcolor='#FFFFFF'>"
fileOutput.writeline "                                    <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.writeline "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Last Scanned</i></b></TD></TR>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Date/Time</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & DateTime & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>System Uptime</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Uptime & " hours</i></td></tr>"
fileOutput.writeline "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Information</i></b></TD></TR>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Workstation ID</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & WKID & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Domain</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Domain & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>UserName</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & UserName & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General OS Information</i></b></TD></TR>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Operating System</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & WKOS & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Service Pack</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & ServicePack & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Computer Information</i></b></TD></TR>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Manufacturer</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Manufacturer & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Model</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Model & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Hardware Information</i></b></TD></TR>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>CPU</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & CPUDesc & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Memory</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & TotalMemory & " MB</i></td></tr>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Total HD Space</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & TotalHDSpace & " GB</i></td></tr>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Free HD Space</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & FreeHDSpace & " GB</i></td></tr>"
fileOutput.writeline "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>General Video Card Information</i></b></TD></TR>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Video Card</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & VideoCard & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Resolution</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Resolution & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Memory</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & VideoMemory & " MB</i></td></tr>"
fileOutput.writeline "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Default Printer Information</i></b></TD></TR>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Printer</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & Printer & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD width='30%' align='left' bgcolor='#e0e0e0'>Port Name</TD><td width='70%' bgcolor=#f0f0f0 align=left><i>" & PortName & "</i></td></tr>"
fileOutput.writeline "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Shared Directories</i></b></TD></TR>"
'This sextion lists all the current shares enabled on the PC.
fileOutput.writeline "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.writeline "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.writeline "                                                <TR><TD width='30%' align='center' bgcolor='#e0e0e0'><b>Name</b></td><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Path</b><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Description</b></td><tr>"
Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")
For each objShare in colShares
    fileOutput.writeline "                                                <TR><TD width='30%' align='left' bgcolor='#f0f0f0'><i>" & objShare.Name & "</i></TD><td bgcolor=#f0f0f0 align=left><i>" & objShare.Path & "</i></TD><td bgcolor=#f0f0f0 align=left><i>" & objShare.Caption & "</i></td></tr>"
Next
fileOutput.writeline "                                            </table>"
fileOutput.writeline "                                        </td></tr>"
'This section lists all the current services and their status.
fileOutput.writeline "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Current Service Information</i></b></TD></TR>"
fileOutput.writeline "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.writeline "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.writeline "                                                <TR><TD width='70%' align='center' bgcolor='#e0e0e0'><b>Service Name</b></td><TD width='30%' align='center' bgcolor='#e0e0e0'><b>Service State</b></td><tr>"
Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objService in colRunningServices
fileOutput.writeline "                                            <TR><TD align='left' bgcolor='#f0f0f0'>" & objService.DisplayName & "</TD><td bgcolor=#f0f0f0 align=center><i>" & objService.State & "</i></td></tr>"
Next
fileOutput.writeline "                                            </table>"
fileOutput.writeline "                                        </td></tr>"
'This section lists all the current running processes and some information.
fileOutput.writeline "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Current Process Information</i></b></TD></TR>"
fileOutput.writeline "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
fileOutput.writeline "                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
fileOutput.writeline "                                                <TR><TD width='10%' align='center' bgcolor='#e0e0e0'><b>PID</b></td><TD width='35%' align='center' bgcolor='#e0e0e0'><b>Process Name</b></td><TD width='40%' align='center' bgcolor='#e0e0e0'><b>Owner</b></td><TD width='15%' align='center' bgcolor='#e0e0e0'><b>Memory</b></td></tr>"
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process")
For Each objProcess in colProcessList
colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)
fileOutput.writeline "                                                <TR><TD align='center' bgcolor='#f0f0f0'>" & objProcess.Handle & "</td><TD align='center' bgcolor='#f0f0f0'>" & objProcess.Name & "</td><TD align='center' bgcolor='#f0f0f0'>" & strUserDomain & "\" & strNameOfUser & "</td><TD align='center' bgcolor='#f0f0f0'>" & objProcess.WorkingSetSize/1024 & " kb</td><tr>"
Next
fileOutput.writeline "                                            </table>"
fileOutput.writeline "                                        </td></tr>"

'This section lists all the currently installed software on the machine.
fileOutput.writeline "                                        <TR><TD align='center' bgcolor='#d0d0d0' colspan='2'><b><i>Installed Software</i></b></TD></TR>"
fileOutput.writeline "                                        <tr><td colspan='2' bgcolor='#f0f0f0'>"
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")
For Each objSoftware in colSoftware
    fileOutput.writeline"                                            <TABLE width='100%' cellspacing='0' cellpadding='2' border='1' bordercolor='#c0c0c0' bordercolordark='#ffffff' bordercolorlight='#c0c0c0'>"
    fileOutput.writeline"                                                <tr><td align=left bgcolor='#e0e0e0'><b>Caption:</b></td><td colspan=2 bgcolor=#f0f0f0>" & objSoftware.Caption & "</td></tr>"
    fileOutput.writeline"                                                <tr><td align=left bgcolor='#e0e0e0'><b>Install Location:</b></td><td colspan=2 bgcolor=#f0f0f0>" & objSoftware.InstallLocation & "</td></tr>"
    fileOutput.writeline"                                                <tr><td width=30% align=center bgcolor='#e0e0e0'><b>Name</b></td><td width=30% align=center bgcolor='#e0e0e0'><b>Vendor</b></td><td width=30% align=center bgcolor='#e0e0e0'><b>Version</b></td></tr>"
    fileOutput.writeline"                                                <tr><td align=center bgcolor=#f0f0f0>" & objSoftware.Name & "</td><td align=center bgcolor=#f0f0f0>" & objSoftware.Vendor & "</td><td align=center bgcolor=#f0f0f0>" & objSoftware.Version & "</td></tr>"
    fileOutput.writeline"                                                <tr height=2><td height=10 align=center bgcolor=midnightblue colspan=3></td></tr>"
    fileOutput.writeline"                                            </table>"
Next

fileOutput.writeline "                                        </td></tr>"
fileOutput.writeline "                                    </table>"
fileOutput.writeline "                                </td></tr>"
fileOutput.writeline "                            </table>"
fileOutput.writeline "                        </td></tr>"
fileOutput.writeline "                    </table>"
fileOutput.writeline "                </td></tr>"
fileOutput.writeline "            </table>"
fileOutput.writeline "            <p><small></small></p>"
fileOutput.writeline "        </center>"
fileOutput.writeline "    </body>"
fileOutput.writeline "<html>"
fileOutput.close