+ Post New Thread
Results 1 to 9 of 9
Scripts Thread, Test 2 scripts on Dell / Lenovo laptops or desktops in Coding and Web Development; Script One : Code: Dim objWMIService Dim colItems strComputer = "." Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set ...
  1. #1

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,213
    Thank Post
    2,766
    Thanked 935 Times in 875 Posts
    Rep Power
    343

    Test 2 scripts on Dell / Lenovo laptops or desktops

    Script One :

    Code:
    Dim objWMIService
    Dim colItems
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct",,48)
    For Each objItem in colItems
    msgbox "IdentifyingNumber: " & objItem.IdentifyingNumber & vbcrlf & _
        "Name: " & objItem.Name & vbcrlf & _
        "Vendor: " & objItem.Vendor & vbcrlf & _
        "Version: " & objItem.Version
    Next
    Script Two :

    Code:
    Dim objWMIService
    Dim colItems1, manu, model
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems1 = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
    
    For Each Item In colItems1
    manu = Item.Manufacturer
    model = Item.Model    
    Next
    
    msgbox manu & vbcrlf & model
    If someone can post back with results of each one ( one from a Lenovo machine and one from a dell machine )

    The thing I am interested in finding out is between the two which one uses the numerical model number ie 7514A87 ( for an M58 ) vs which one comes back with the string model ie actual model name ie M58 or D630 etc ??

    Basically just trying to refine my script and need to know which way is the better way of getting the information I am after.

  2. #2

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,213
    Thank Post
    2,766
    Thanked 935 Times in 875 Posts
    Rep Power
    343
    bump - anyone ?

  3. #3

    broc's Avatar
    Join Date
    Jan 2006
    Location
    England
    Posts
    2,046
    Thank Post
    104
    Thanked 401 Times in 265 Posts
    Rep Power
    149
    ran them on a Dell Latitude E6500 notebook

    Script 1 reports

    IdentifyingNumber : zzzzzzz <== which is my DELL Service tag ID
    Name: Latitude E6500
    Vendor: Dell Inc
    Version:

    Script 2 reports

    Dell Inc
    Latitude E6500

  4. Thanks to broc from:

    mac_shinobi (24th January 2014)

  5. #4


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,105
    Thank Post
    203
    Thanked 2,383 Times in 1,763 Posts
    Rep Power
    703
    According to this, Lenovo puts the model name under 'Version'.

  6. Thanks to Arthur from:

    mac_shinobi (24th January 2014)

  7. #5

    AngryTechnician's Avatar
    Join Date
    Oct 2008
    Posts
    3,722
    Thank Post
    695
    Thanked 1,206 Times in 759 Posts
    Rep Power
    393
    Arthur is correct.

    Output from Dell OptiPlex 960:



    Output from Lenovo ThinkPad X131e:

    Attached Images Attached Images
    Last edited by AngryTechnician; 26th November 2012 at 04:30 PM.

  8. #6

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,213
    Thank Post
    2,766
    Thanked 935 Times in 875 Posts
    Rep Power
    343
    Whats the best way of making the script output the same info regardless of being dell or lenovo ?

    Will post my full script tomorrow. Thanks

  9. #7


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,207
    Thank Post
    218
    Thanked 812 Times in 694 Posts
    Rep Power
    274
    Quote Originally Posted by mac_shinobi View Post
    Whats the best way of making the script output the same info regardless of being dell or lenovo ?

    Will post my full script tomorrow. Thanks
    something along the lines of copy the data to variables and
    if vendor= "Dell Inc" model="which ever item gives the desired output"
    if vendor= "lenovo" model="which ever item gives the desired output"
    wscript.echo vendor &" " & model

  10. #8

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,213
    Thank Post
    2,766
    Thanked 935 Times in 875 Posts
    Rep Power
    343
    My Script thus far ( which I have named version 3.6 ), not tested it between Dell and or Lenovo's 100% but think it works ok

    Code:
    const HKEY_CURRENT_USER = &H80000001
    const HKEY_LOCAL_MACHINE = &H80000002
    Const ForReading = 1, ForWriting = 2, ForAppending = 8 
    strComputer = "."
    Set StdOut = WScript.StdOut
    Dim username, asset, hdd, manuhdd
    Dim colIPResults, objFile, objFSO, objNIC, objWMI, objWSHNetwork, strAddresses, strIPAddress, strWQL, strComp, osVer
    Dim strRAM
    dim filesys, filetxt
    dim newfolder
    Dim usbPath
    Dim spVer
    Dim strSerial, strModel, strVendor, strNumModel
    Set objNetwork = CreateObject("Wscript.Network")
    Set filesys = CreateObject("Scripting.FileSystemObject")
    username = objNetwork.username
    strComputer = objNetwork.ComputerName
    usbPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
    
    Sub DestroyObjects()
    If IsObject(objWMI) Then Set objWMI = Nothing
    If IsObject(objWSHNetwork) Then Set objWSHNetwork = Nothing
    End Sub
    
    Dim strMAC
    Set objWSHNetwork = CreateObject("WScript.Network")
    Set objWMI = GetObject("WinMGMTS:root\cimv2")
    strWQL = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'"
    Set colIPResults = objWMI.ExecQuery(strWQL)
    For Each objNIC In colIPResults
    For Each strIPAddress in objNIC.IPAddress
    If strAddresses = "" Then
    strAddresses = strIPAddress
    Else
    strAddresses = strAddresses
    End If
    Next
    strMAC = objNIC.MACAddress
    Next
    
    'IPAddress
    
    
    'Set objWMIService = GetObject("WinMGMTS:root\cimv2")
    'Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=True",,48)
    'For Each objItem in colItems
     '  strMAC = objItem.MACAddress
    'Next
    
    If strAddresses ="0.0.0.0" Or strAddresses ="" or strAddresses = "undefined" Then
        strAddresses = "No Connection Detected or invalid ip address"
    Else
        strAddresses = strAddresses
    End If
    
    DestroyObjects()
    
    'Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    'Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
    'For Each Item In colItems
    'manu = Item.Manufacturer
    '    model = Item.Model    
    'Next
    
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct",,48)
    For Each objItem in colItems
    Select Case objItem.Vendor
    Case "Dell Inc.":
    
    strSerial = objItem.IdentifyingNumber
    strModel = objItem.Name
    strVendor = objItem.Vendor 
    strNumModel = objItem.Version
    
    If strNumModel = "" Or IsNull(strNumModel)=true Then
    strNumModel = "N/A"
    End If
    
    
    Case "LENOVO":
    
    strSerial = objItem.IdentifyingNumber
    strNumModel =  objItem.Name
    strVendor =  objItem.Vendor 
    strModel = objItem.Version
    
    
    End Select
    
    Next
    
    
    
    
    
    
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMemory", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
    totalMemory = 0
    For Each item In colItems
        totalMemory = totalMemory + item.Capacity / (1024^2)
    Next
    strRam = FormatNumber((totalMemory / 1024), 2) & " Gb"
    
    'Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS")
    'For Each objItem in colItems
    '    serial = objItem.SerialNumber
    'Next
    
    Set colItems = objWMIService.ExecQuery("Select * from Win32_SystemEnclosure")
    For Each objItem in colItems
    If Len(objItem.SMBIOSAssetTag) <= 0 Then
        asset = "N/A"
    Else
        asset =  objItem.SMBIOSAssetTag
        
    End If
    Next
    
    Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
    
    strKeyPath = "HARDWARE\DESCRIPTION\System\CentralProcessor\0"
    strValue = "ProcessorNameString"
     
    objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValue,strScriptStatus
    
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colDisks = objWMIService.ExecQuery("select * from Win32_DiskDrive where Name like '%PHYSICALDRIVE0%'")
    For Each objDisk in colDisks
         
                hdd = ConvertSize(objDisk.Size)
                manuhdd = Int(objDisk.Size /(1000000000)) & " GB" 
    
    Next
    
    Set oWMI = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set QueryWMI = oWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem")
    For Each oItem In QueryWMI
    spVer = oItem.Caption & " with Service Pack " & oItem.ServicePackMajorVersion
    osVer = oItem.Version
    Next
    
    Set filetxt = filesys.OpenTextFile(usbPath & "\" & ucase(username) & " - " & Trim(strComputer) & ".htm" , 2, True) 
    'filetxt.WriteLine "Username,Manufacturer,Serial Number,Model,Computer Name,RAM,HDD,Asset Tag,Processor"
    'filetxt.WriteLine ucase(username) & "," & manu & "," & serial & "," & model & "," & strComputer & "," & strRAM & "," & hdd & "( " & manuhdd & " )" &  "," & asset & "," & strScriptStatus
    
    filetxt.WriteLine "<H1>Computer Spec for : " & strComputer & "</H1>"
    filetxt.WriteLine "<Center>"
    filetxt.WriteLine "<Table Border=1>"
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Username :</b></td>"
    filetxt.WriteLine "<td>" & ucase(username) & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Operating System & Service Pack Level :</b></td>"
    filetxt.WriteLine "<td>" & spVer & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Operating System Version :</b></td>"
    filetxt.WriteLine "<td>" & osVer & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Manufacturer :</b></td>"
    filetxt.WriteLine "<td>" & strVendor & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Serial Number :</b></td>"
    filetxt.WriteLine "<td>" & strSerial & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Numerical Model :</b></td>"
    filetxt.WriteLine "<td>" & strNumModel & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Model Name :</b></td>"
    filetxt.WriteLine "<td>" & strModel & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Computer Name :</b></td>"
    filetxt.WriteLine "<td>" & strComputer & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>I.P Address :</b></td>"
    filetxt.WriteLine "<td>" & strAddresses & "</td>"
    filetxt.WriteLine "</tr>"
    
    'filetxt.WriteLine "<tr>"
    'filetxt.WriteLine "<td><b>MAC Address :</b></td>"
    'filetxt.WriteLine "<td>" & strMAC & "</td>"
    'filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Total RAM :</b></td>"
    filetxt.WriteLine "<td>" & strRAM & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Actual HDD Capacity :</b></td>"
    filetxt.WriteLine "<td>" & HDD & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Manufacturer HDD Capacity :</b></td>"
    filetxt.WriteLine "<td>" & manuhdd & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Asset Tag :</b></td>"
    filetxt.WriteLine "<td>" & asset & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>Processor :</b></td>"
    filetxt.WriteLine "<td>" & Trim(strScriptStatus) & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "<tr>"
    filetxt.WriteLine "<td><b>A.D Description :</b></td>"
    filetxt.WriteLine "<td>" & ProperCase(username) & space(1) & strModel & space(1) & "(" & strSerial & ")" & "</td>"
    filetxt.WriteLine "</tr>"
    
    filetxt.WriteLine "</table>"
    filetxt.WriteLine "<Center>"
    filetxt.WriteLine "<P>"
    filetxt.WriteLine "==========================================================="
    
    
    Dim ObjExec
    Dim strFromProc
    Dim strOutput
    'output.innerhtml = ""
    Set objShell = CreateObject("WScript.Shell")
    Set ObjExec = objShell.Exec("%comspec% /c ipconfig /all 2>&1")
    Do
        strFromProc = ObjExec.StdOut.ReadLine()
        strOutput = strOutput & strFromProc & "<br>"
        
    Loop While Not ObjExec.Stdout.atEndOfStream
    
    filetxt.WriteLine "<Table Border=1>"
    filetxt.WriteLine "<td>" & strOutput & "</td>"
    filetxt.WriteLine "</table>"
    
    
    
    
    
    filetxt.Close 
    
    msgbox ucase(username) & vbcrlf & spVer & vbcrlf & osVer & vbcrlf & strVendor & vbcrlf & strModel & " ( " & strNumModel & " ) " & vbcrlf & strSerial & vbcrlf & asset & vbcrlf & vbcrlf & strComputer & vbcrlf & strAddresses  & vbcrlf & strScriptStatus & vbcrlf & strRAM & vbcrlf & hdd & "( " & manuhdd & " )" & vbcrlf & ProperCase(username) & space(2) & strModel & space(2) & "(" & strSerial & ")"
    
    wscript.sleep 1000
    
    
    Function ConvertSize(Size) 
    Do While InStr(Size,",") 'Remove commas from size 
        CommaLocate = InStr(Size,",") 
        Size = Mid(Size,1,CommaLocate - 1) & _ 
            Mid(Size,CommaLocate + 1,Len(Size) - CommaLocate) 
    Loop
    
    Suffix = " Bytes" 
    If Size >= 1024 Then suffix = " KB" 
    If Size >= 1048576 Then suffix = " MB" 
    If Size >= 1073741824 Then suffix = " GB" 
    If Size >= 1099511627776 Then suffix = " TB" 
    
    Select Case Suffix 
        Case " KB" Size = Round(Size / 1024, 1) 
        Case " MB" Size = Round(Size / 1048576, 1) 
        Case " GB" Size = Round(Size / 1073741824, 1) 
        Case " TB" Size = Round(Size / 1099511627776, 1) 
    End Select
    
    ConvertSize = Size & Suffix 
    End Function
    
    Function ProperCase(sText)
        '*** Converts text to proper case e.g.  ***'
        '*** surname = Surname                  ***'
        '*** o'connor = O'Connor                ***'
         
            Dim a, iLen, bSpace, tmpX, tmpFull
         
            iLen = Len(sText)
            For a = 1 To iLen
            If a <> 1 Then 'just to make sure 1st character is upper and the rest lower'
                If bSpace = True Then
                    tmpX = UCase(mid(sText,a,1))
                    bSpace = False
                Else
                tmpX=LCase(mid(sText,a,1))
                    If tmpX = " " Or tmpX = "'" Or tmpX ="." Then bSpace = True
                End if
            Else
                tmpX = UCase(mid(sText,a,1))
            End if
            tmpFull = tmpFull & tmpX
            Next
            ProperCase = tmpFull
        End Function
    
    Set objMemory = Nothing
    Set objWMIService = Nothing

  11. #9


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,207
    Thank Post
    218
    Thanked 812 Times in 694 Posts
    Rep Power
    274
    by the looks you are pulling various pc details out via wmi for a pc and stuffing them into a csv file pcname.csv. If it helps there are a few simialr projects already on here that do that (and im currently rewriting mine as its got bodged and added to over the years so im trying to write a neater easier to understand version atm)

    current finished version gives this as an output

    FPS-SUITE-16,OEGStone AWRDACPI,Intel(R) Pentium(R) D CPU 2.66GHz,2048 MB,76 GB,40 GB,301136-009,Microsoft Windows 7 Enterprise sp 1,00:16:76:7FC:61,Overall -1 - CPU - 4.4 - Memory - 4.4 - Graphics - 1 - Gaming graphics - 1 - hdd - 5.3,domain\somekid,100 Mbps-,24/01/2014,

    and another merged csv file for webpage viewing

    Code:
    Option Explicit
    'On Error Resume Next
    'webinfo v8
    
    dim outputstring, computermodel, pcmake, pcmodel, cpu, ram, hddcapacity, hddfree, serialno, macaddress, operatingsystem, csvoutput, csvoutput2
    dim stcomputer, colitems, objItem, colcpu, colPhysicalMemory, objPhysicalMemory, intMemory, colDisks, objhdd
    dim colComputerSystem, colOperatingSystems, objOperatingSystem, colBIOS, objBIOS, colnicconfig, objnicconfig
    dim objwmiservice, hddtemp, weidata, colWSA, operatingsystemno, Lastuser, oreg, spath, svalue, strvalue, svaluename
    dim adoutputstring, adoRecordset, adoConnection, objRootDSE, objNetwork, objComputer, existing, basedata
    dim pcname, wshShell, strDirectory, strFile, objFSO, objFolder, objFile, objTextFile, myDateString
    dim colnet,objnet, linkspeed, objWMIService2, strline, strNewContents, strDirectory2, strFile2, objfolder2, objfile2
    
    stcomputer = "."
    myDateString = Date()
    
    Set objRootDSE = GetObject("LDAP://RootDSE")
    Set objNetwork = WScript.CreateObject("WScript.Network")
    Set objWMIService = GetObject("winmgmts:\\" & stcomputer & "\root\CIMV2") 
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") 
    Set colcpu = objWMIService.ExecQuery("Select * from Win32_Processor")
    Set colPhysicalMemory = objWMIService.ExecQuery("Select * From Win32_PhysicalMemory")
    set coldisks = objWMIService.ExecQuery("Select * From Win32_LogicalDisk") 
    Set colComputerSystem = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
    Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
    Set colBIOS = objWMIService.ExecQuery("Select * From Win32_BIOS")
    Set colnicconfig = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    Set colWSA = objWMIservice.ExecQuery("Select * From Win32_WinSAT")
    Set adoConnection = CreateObject("ADODB.Connection")
    adoConnection.Provider = "ADsDSOObject"
    adoConnection.Open "Active Directory Provider"
    Set adoRecordset = adoConnection.Execute("<LDAP://" & objRootDSE.Get("defaultNamingContext") & ">;(&(objectCategory=Computer)(name=" & objNetwork.Computername & "));adspath;subtree")
    Set wshShell = WScript.CreateObject( "WScript.Shell" )
    Set objWMIService2 = GetObject("winmgmts:\\" & stComputer & "\root\WMI")
    Set colnet = objWMIService2.ExecQuery("SELECT * FROM MSNdis_LinkSpeed",,48)
    basedata= "MAC Address,Network Adapter,IP Address,Computer Name,GUID/UUID,GUID/UUID Mac Address Conversion,Total RAM Memory,Sid,RAM Memory Bank Label,RAM Memory Capacity,RAM Memory Device Locator,RAM Memory Manufacturer,Computer Manufacturer,Computer Model,Computer Serial,Motherboard Manufacturer,Motherboard Model,Motherboard Product,Motherboard Serial Number,Motherboard Version,Hard Disk Drive Letter,Hard Disk Size,Hard Disk Free Space,Hard Disk Volume Serial Number,Hard Disk Manufacturer,Hard Disk Model,Hard Disk Device ID,Hard Disk Interface Type,Hard Disk Partitions,Hard Disk Total Cylinders,Hard Disk Total Heads,Hard Disk Total Sectors,Hard Disk Total Tracks,Hard Disk Tracks Per Cylinder,Processor Name,Processor Type,Processor Family,Sound Card Manufacturer,Sound Card Product Name,Sound Card Description,Sound Card Name,Video Card Name,Video Card Setting ID,Floppy Manufacturer,Floppy Name,Floppy Device ID,CDROMCaptionSet,CDROMDescriptionSet,CDROMDeviceIDSet,CDROMDriveSet,CDROMManufacturerSet,CDROMNameSet,BIOS Version,Dell Service Tag,Date of Log,Time of Log,serial no"
    
    
    'write file 1 location
    pcname = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
    strDirectory = "\\gateway\logs$\pc2\"
    strFile = pcname & ".csv"
    
    'write file 2 location
    
    strDirectory2 = "\\gateway\inventory$\"
    strFile2 = "inventorylog.csv"
    
    
    'make-model
    For Each objItem In colItems 
    	computermodel= objItem.Manufacturer & " " & objItem.Model
    	computermodel=Replace(computermodel,",","")
    	pcmake=objItem.Manufacturer
    	pcmake=Replace(pcmake,",","")
    	pcmodel=objItem.Model
    	'wscript.echo computermodel
    Next
    
    ' Create the File System Object
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    'cpu info
    For Each objItem in colcpu
        cpu = objItem.Name
    	'wscript.echo cpu
    Next
    
    'ram
    If Not colPhysicalMemory Is Nothing Then
    	 intMemory = 0
    	 For Each objPhysicalMemory In colPhysicalMemory
    		 intMemory = intMemory + Int(objPhysicalMemory.Capacity)
    	 Next
    	 ram = (intMemory / 1024 / 1024 ) & " MB"
    	 'wscript.echo ram
    End If
    
    'hdd capacity
    for each objhdd in coldisks
    	If objhdd.DeviceID = "C:" Then
    		hddcapacity = int(objhdd.Size/1073741824) & " GB"
    		hddfree = int(objhdd.freespace/1073741824) & " GB"
    		'wscript.echo hddfree
    	end if
    next
    
    'windows version
    For Each objOperatingSystem in colOperatingSystems
        operatingsystem = objOperatingSystem.Caption & " sp " & objOperatingSystem.ServicePackMajorVersion
    	operatingsystemno = objOperatingSystem.Version
    		'wscript.echo operatingsystem
    	Next
    
    'serial no
    If Not colBIOS Is Nothing Then
    	 For Each objBIOS in colBIOS
    		 serialno = objBIOS.SerialNumber
    		 'wscript.echo serialno
    	 Next
    End If
    
    'mac address(s)
    If Not colnicconfig Is Nothing Then
    	 For Each objnicconfig in colnicconfig
    		 If macaddress <> "" Then
    			 macaddress = macaddress & " - "
    		 End If
    		 macaddress = macaddress & objnicconfig.MACAddress
    		 'wscript.echo macaddress
    	 Next
    End If
    
    'windows experience
    operatingsystemno = Left( operatingsystemno, 3 )  
    if operatingsystemno >5.5 then
    	'vista+
    	For Each objItem in colWSA
    	'weidata = "Overall -" & "na" & " - CPU - " & "na" & " - Memory - " & "na" & " - Graphics - " & "na" & " - Gaming graphics - " & "na" & " - hdd - " & "na" 
    		weidata = "Overall -" & objItem.WinSPRLevel & " - CPU - " & objItem.CPUScore & " - Memory - " & objItem.MemoryScore & " - Graphics - " & objItem.GraphicsScore & " - Gaming graphics - " & objItem.D3DScore & " - hdd - " & objItem.DiskScore
    	next
    else
    	'xp-
    	weidata = "Overall -" & "na" & " - CPU - " & "na" & " - Memory - " & "na" & " - Graphics - " & "na" & " - Gaming graphics - " & "na" & " - hdd - " & "na" 
     end if
    
     'last user
     if operatingsystemno >5.5 then  
    	'vista+
    	Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
    	Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & stcomputer & "/root/default:StdRegProv")
    	If Err.Number <> 0 Then
    		On Error Goto 0
    	Else
    		On Error Goto 0
    		sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI"
    		sValueName = "LastLoggedonUser"
    		If oReg.GetStringValue(HKLM, sPath, sValueName, sValue) = 0 Then
    			lastuser = sValue
    		Else
    			lastuser = "unknown" & stcomputer
    		End If
    	End If
    else
    	'xp-
    	Const HKEY_LOCAL_MACHINE = &H80000002
    	Set oreg=GetObject("winmgmts:\\" & stComputer & "\root\default:StdRegProv")
    	spath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon"
    	svalue = "DefaultUserName"
    	oreg.GetStringValue HKEY_LOCAL_MACHINE, spath, svalue, strValue
    	lastuser=strvalue
    	svalue = "DefaultDomainName"
    	oreg.GetStringValue HKEY_LOCAL_MACHINE, spath, svalue, strValue
    	lastuser = strvalue & "\" & lastuser
    end if
     
     'Scans data for Net Speed
    For Each objnet in colnet
    
    'Removes "slow/unused links"
    if objnet.NdisLinkSpeed/10 > 1000 then
    	linkspeed= objnet.NdisLinkSpeed/10000 & " Mbps" & "-" & linkspeed '& "-" & objnet.NdisLinkSpeed/10000 & " Mbps"
    end if
    next
     
    'concatanate data for output
    outputstring = computermodel & "," & cpu &"," & ram &"," & hddcapacity & ","  & serialno & "," & macaddress & "," 
    csvoutput = pcname & "," & computermodel & "," & cpu &"," & ram &"," & hddcapacity& "," & hddfree & "," & serialno & "," & operatingsystem & "," & macaddress & "," & weidata & "," & Lastuser & "," & linkspeed &"," & myDateString &","
    csvoutput2 = macaddress & ", "&" ,"& "," & pcname & "," & "," & "," & ram &"," &"," &"," &"," &"," &"," & pcmake & "," & pcmodel & "," & serialno & ","  & "," & "," & "," & "," & "," & "," & hddcapacity & "," & hddfree & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & cpu & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "," & "dell," & myDateString & "," & ","  & serialno & "," & operatingsystem & "," & Lastuser
    ' wscript.echo outputstring
    
    ' Check that the strDirectory folder exists
    If objFSO.FolderExists(strDirectory) Then
       Set objFolder = objFSO.GetFolder(strDirectory)
    Else
       Set objFolder = objFSO.CreateFolder(strDirectory)
       'WScript.Echo "Just created " & strDirectory
    End If
    
    If objFSO.FileExists(strDirectory & strFile) Then
       Set objFolder = objFSO.GetFolder(strDirectory)
    Else
       Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
       'Wscript.Echo "Just created " & strDirectory & strFile
    End If 
    
    set objFile = nothing
    set objFolder = nothing
    ' OpenTextFile Method needs a Const value
    ' ForAppending = 8 ForReading = 1, ForWriting = 2
    Const ForAppending = 2
    
    Set objTextFile = objFSO.OpenTextFile _
    (strDirectory & strFile, ForAppending, True)
    
    ' Writes result every time you run this VBScript
    objTextFile.WriteLine(csvoutput)
    objTextFile.Close
    
    If Err.Number <> 0 Then
    	 MsgBox "Query Error: " & Err.Description
    	 WScript.Quit
    End If
    '********************************************
    '2nd file
    '********************************************
    
    
    ' Check that the strDirectory folder exists
    If objFSO.FolderExists(strDirectory2) Then
       Set objFolder2 = objFSO.GetFolder(strDirectory2)
    Else
       Set objFolder2 = objFSO.CreateFolder(strDirectory2)
       'WScript.Echo "Just created " & strDirectory2 & strfile2 & "bit1"
    End If
    
    If objFSO.FileExists(strDirectory2 & strFile2) Then
       Set objFolder2 = objFSO.GetFolder(strDirectory2)
    Else
       Set objFile2 = objFSO.CreateTextFile(strDirectory2 & strFile2)
       'Wscript.Echo "Just created " & strDirectory2 & strFile2 &"bit2"
       objfile2.close
       Set objFile2 = objFSO.OpenTextFile((strDirectory2 & strFile2), ForWriting)
       objFile2.WriteLine(basedata)
       objfile2.close
    End If 
    
    Const ForReading = 1
    Const ForWriting = 2
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile2 = objFSO.OpenTextFile((strDirectory2 & strFile2), ForReading)
    
    Do Until objFile2.AtEndOfStream
        strLine = objFile2.ReadLine
        'If InStr(left(strLine,17), macaddress) = 0 Then
    	If InStr (strLine, macaddress) = 0 Then
    	        strNewContents = strNewContents & strLine & vbCrLf
        End If
    Loop
    
    objFile2.Close
    
    Set objFile2 = objFSO.OpenTextFile((strDirectory2 & strFile2), ForWriting)
    objFile2.Write strNewContents
    objFile2.WriteLine(csvoutput2)
    
    objFile2.Close
    
    If Not adoRecordset.EOF Then
    	 Set objComputer = GetObject(adoRecordset.Fields(0).Value)
    	 existing = objcomputer.Description
    	 if left (existing,1) = "#" and not right (existing,1) = "#" then outputstring = existing & " : " & outputstring & "#"
    	 if left (existing,1) = "#" and right (existing,1) = "#" then
    		'msgbox "data"
    		wscript.quit
    	end if
    if not objComputer.Description = outputstring then
    		'msgbox "diff"
    		objComputer.Put "description", outputstring
    		objComputer.SetInfo
    	else
    		'msgbox "matches"
    	 end if
    	  
    End If
    
    If Err.Number <> 0 Then
    	 MsgBox "Write Error: " & Err.Description
    	 WScript.Quit
    End If
    but as its had stuff bolted on over the years as i said its a bit messy

SHARE:
+ Post New Thread

Similar Threads

  1. UEFI or BIOS to install 2008R2 on DELL T610
    By edutech4schools in forum Windows Server 2008 R2
    Replies: 4
    Last Post: 13th May 2011, 10:43 AM
  2. Laptops or Desktop
    By ba9ag in forum Hardware
    Replies: 17
    Last Post: 12th March 2010, 08:44 PM
  3. Replies: 23
    Last Post: 11th March 2010, 03:59 PM
  4. Laptop or Desktop
    By jcs808 in forum How do you do....it?
    Replies: 16
    Last Post: 17th March 2009, 12:07 PM
  5. Can anyone supply a quote for laptop or desktop?
    By rocknrollstar in forum Recommended Suppliers
    Replies: 1
    Last Post: 4th March 2009, 08:06 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •