mac_shinobi Posted November 26, 2012 Posted November 26, 2012 Script One : 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 : 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.
broc Posted November 26, 2012 Posted November 26, 2012 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 1
Arthur Posted November 26, 2012 Posted November 26, 2012 According to this, Lenovo puts the model name under 'Version'. 1
AngryTechnician Posted November 26, 2012 Posted November 26, 2012 (edited) Arthur is correct. Output from Dell OptiPlex 960: Output from Lenovo ThinkPad X131e: Edited November 26, 2012 by AngryTechnician
mac_shinobi Posted January 21, 2014 Author Posted January 21, 2014 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
sted Posted January 24, 2014 Posted January 24, 2014 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
mac_shinobi Posted January 24, 2014 Author Posted January 24, 2014 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 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 "Computer Spec for : " & strComputer & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Username :" filetxt.WriteLine "" & ucase(username) & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Operating System & Service Pack Level :" filetxt.WriteLine "" & spVer & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Operating System Version :" filetxt.WriteLine "" & osVer & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Manufacturer :" filetxt.WriteLine "" & strVendor & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Serial Number :" filetxt.WriteLine "" & strSerial & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Numerical Model :" filetxt.WriteLine "" & strNumModel & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Model Name :" filetxt.WriteLine "" & strModel & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Computer Name :" filetxt.WriteLine "" & strComputer & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "I.P Address :" filetxt.WriteLine "" & strAddresses & "" filetxt.WriteLine "" 'filetxt.WriteLine "" 'filetxt.WriteLine "MAC Address :" 'filetxt.WriteLine "" & strMAC & "" 'filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Total RAM :" filetxt.WriteLine "" & strRAM & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Actual HDD Capacity :" filetxt.WriteLine "" & HDD & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Manufacturer HDD Capacity :" filetxt.WriteLine "" & manuhdd & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Asset Tag :" filetxt.WriteLine "" & asset & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "Processor :" filetxt.WriteLine "" & Trim(strScriptStatus) & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "A.D Description :" filetxt.WriteLine "" & ProperCase(username) & space(1) & strModel & space(1) & "(" & strSerial & ")" & "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine "" filetxt.WriteLine " " 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 & " " Loop While Not ObjExec.Stdout.atEndOfStream filetxt.WriteLine "" filetxt.WriteLine "" & strOutput & "" filetxt.WriteLine "" 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
sted Posted January 24, 2014 Posted January 24, 2014 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® Pentium® D CPU 2.66GHz,2048 MB,76 GB,40 GB,301136-009,Microsoft Windows 7 Enterprise sp 1,00:16:76:7F:DC: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 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(";(&(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
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now