Aşağıdaki windows script (*.vbs) Windows200/XP/VISTA/7/2003/2008 işletim sistemlerinde çalışmaktadır, bilgisayar hakkındaki bilgileri text dosyası olarak önce kullanıcının temp klasörüne sonrada (istenir ise) network üzerinde ki kaynağa (smb) söz konusu text dosyasını kopyalayabilmektedir.
Bu script ile toplayabileceğiniz bilgilerin bir kısmı aşağıda sıralanmıştır.
Bilgisayar adı, Boot zamanı, Makine tipi, kullanıcı adı, local admin group üyeleri, OS bilgileri (SP,version), donanım bilgileri, yüklü uygulamalar,
Not: Bazı kodlar internet’ten elde edilmiştir.
‘ 20 / 04 /2011 — Emrullah Tahir Ekmekçi
‘ user and computer data collection with Text file
‘ 1.9
On Error Resume Next ‘ If we do not get any or portion info from computer, will try again copy file for determine computer
‘ Gathered data will be copying this network path.
Targetpath = “181.23.112.134SharedSL”
‘Temp Dir
Set objShell = CreateObject(“Wscript.Shell”)
TempDir = objShell.ExpandEnvironmentStrings(“%temp%”)
Set objShell = nothing
‘ Computer Name
set wshnetwork=createobject(“wscript.network”)
strComputer=wshnetwork.computername
set wshnetwork=nothing
filename = TempDir & “” & strComputer & “.txt”
SET objWMIDateTime = CREATEOBJECT(“WbemScripting.SWbemDateTime”)
SET objWMI = GETOBJECT(“winmgmts:” & strComputer & “rootcimv2”)
SET colOS = objWMI.InstancesOf(“Win32_OperatingSystem”)
‘ System Last Boot and Up date
FOR EACH objOS in colOS
objWMIDateTime.Value = objOS.LastBootUpTime
LBUT = day(objWMIDateTime.GetVarDate) & “.” & month(objWMIDateTime.GetVarDate) & “.” & year(objWMIDateTime.GetVarDate) & CStr(Right(objWMIDateTime.GetVarDate,9)) & vbcrlf & “UPTIME=” & TimeSpan(objWMIDateTime.GetVarDate,NOW)
NEXT
‘ System Type // Systemtype options will be narrow after gather whole types
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!” & strComputer & “rootcimv2”)
Set colChassis = objWMIService.ExecQuery _
(“Select * from Win32_SystemEnclosure”)
For Each objChassis in colChassis
For Each strChassisType in objChassis.ChassisTypes
Select Case strChassisType
Case 1 SystemType = “Other”
Case 2 SystemType = “Unknown”
Case 3 SystemType = “Desktop”
Case 4 SystemType = “Low Profile Desktop”
Case 5 SystemType = “Pizza Box”
Case 6 SystemType = “Mini Tower”
Case 7 SystemType = “Tower”
Case 8 SystemType = “Portable”
Case 9 SystemType = “Laptop”
Case 10 SystemType = “Notebook”
Case 11 SystemType = “Handheld”
Case 12 SystemType = “Docking Station”
Case 13 SystemType = “All-in-One”
Case 14 SystemType = “Sub-Notebook”
Case 15 SystemType = “Space Saving”
Case 16 SystemType = “Lunch Box”
Case 17 SystemType = “Main System Chassis”
Case 18 SystemType = “Expansion Chassis”
Case 19 SystemType = “Sub-Chassis”
Case 20 SystemType = “Bus Expansion Chassis”
Case 21 SystemType = “Peripheral Chassis”
Case 22 SystemType = “Storage Chassis”
Case 23 SystemType = “Rack Mount Chassis”
Case 24 SystemType = “Sealed-Case PC”
Case Else SystemType = “Unknown”
End Select
Next
Next
‘ very rare but sometimes Select Case could not get any data from strChassisType even “Case Else”
if SystemType = “” or SystemType = ” ” then
SystemType = “Unknown”
end if
‘ Windows installed date
Set dtmInstallDate = CreateObject(“WbemScripting.SWbemDateTime”)
Set colOperatingSystems = objWMIService.ExecQuery (“Select * from Win32_OperatingSystem”)
For Each objOperatingSystem in colOperatingSystems
dtmInstallDate.Value = objOperatingSystem.InstallDate
installd = day(dtmInstallDate.GetVarDate) & “.” & month(dtmInstallDate.GetVarDate) & “.” & year(dtmInstallDate.GetVarDate) & CStr(Right(dtmInstallDate.GetVarDate,9))
Next
‘ Collect Computer Info
ComputerInfo = “[ComputerInfo]” & vbCrLf
ComputerInfo = ComputerInfo & “MachineName=” & strComputer & vbCrLf
ComputerInfo = ComputerInfo & “TempFolder=” &TempDir & vbCrLf
ComputerInfo = ComputerInfo & “LastBoot=” & LBUT & vbCrLf
ComputerInfo = ComputerInfo & “SystemType=” &SystemType & vbCrLf
ComputerInfo = ComputerInfo & “InstalledDate=” &installd & vbCrLf
‘ Username
Set colSoftware = objWMIService.ExecQuery (“SELECT * FROM Win32_Product”)
Set objNetwork = CreateObject(“WScript.Network”)
Username = objNetwork.UserName
ComputerInfo = ComputerInfo & “LogonUser=” &Username & vbCrLf
‘ Collect Members of Local Admin Groups
LocalAdminGroup = LocalAdminGroup & vbCrLf & “[LocalAdminGroup]” & vbCrLf
Set objComp = GetObject(“WinNT://” & strComputer)
objComp.GetInfo
If objComp.PropertyCount > 0 Then
Set objGroup = GetObject(“WinNT://” & strComputer & “/Administrators,group”)
If objGroup.PropertyCount > 0 Then
For Each mem In objGroup.Members
LocalAdminGroup = LocalAdminGroup & “LAGM=” &Right(mem.adsPath,Len(mem.adsPath) – 8) & vbCrLf
Next
Else
LocalAdminGroup = LocalAdminGroup & “LAGM=” & vbCrLf
End If
End If
‘Collect Operation System and CPU info
OsInfo = OsInfo & vbCrLf & “[OsInfo]” & vbCrLf
Set colSettings = objWMIService.ExecQuery (“Select * from Win32_OperatingSystem”)
For Each objOperatingSystem in colSettings
OsInfo = OsInfo & “OSCaption=” & objOperatingSystem.Caption & vbCrLf
OsInfo = OsInfo & “RegisteredUser=” & objOperatingSystem.RegisteredUser & vbCrLf
OsInfo = OsInfo & “SPMa=” &objOperatingSystem.ServicePackMajorVersion & vbCrLf
OsInfo = OsInfo & “SPMi=” &objOperatingSystem.ServicePackMinorVersion & vbCrLf
OsInfo = OsInfo & “OSVersion=” &objOperatingSystem.Version & vbCrLf
Next
Set colSettings = objWMIService.ExecQuery (“Select * from Win32_ComputerSystem”)
For Each objComputer in colSettings
OsInfo = OsInfo & “ComputerManufacturer=” & objComputer.Manufacturer & vbCrLf
OsInfo = OsInfo & “ComputerModel=” & objComputer.Model & vbCrLf
OsInfo = OsInfo & “TotalPhysicalMemory=” & objComputer.TotalPhysicalMemory /10241024+1 & vbCrLf
Next
Cpu = Cpu & vbCrLf & “[Cpu]” & vbCrLf
Set colItems = objWMIService.ExecQuery(“Select * from Win32_Processor”)
For Each objItem in colItems
Cpu = Cpu & “CPUDesc=” & objItem.Description & vbCrLf
Cpu = Cpu & “CPUManufacturer=” & objItem.Manufacturer & vbCrLf
Cpu = Cpu & “CPUClockSpeed=” & objItem.MaxClockSpeed & vbCrLf
Cpu = Cpu & “CPUName=” & objItem.Name & vbCrLf
Next
‘ Collect Bios Info
bios = bios & vbCrLf & “[Bios]” & vbCrLf
Set colBIOS = objWMIService.ExecQuery (“Select * from Win32_BIOS”)
For each objBIOS in colBIOS
bios =bios & “BIOSManufacturer=” & objBIOS.Manufacturer & vbcrlf
bios =bios & “BIOSName=” & objBIOS.Name & vbcrlf
bios =bios & “BIOSReleaseDate=” & objBIOS.ReleaseDate & vbcrlf
bios =bios & “BIOSerialNumber=” & objBIOS.SerialNumber & vbcrlf
bios =bios & “BIOSSMBIOSBIOSVersion=” & objBIOS.SMBIOSBIOSVersion & vbcrlf
bios =bios & “BIOSMBIOSMajorVersion=” & objBIOS.SMBIOSMajorVersion & vbcrlf
bios =bios & “BIOSMBIOSMinorVersion=” & objBIOS.SMBIOSMinorVersion & vbcrlf
bios =bios & “BIOSVersion=” & objBIOS.Version & vbcrlf
Next
Basebord = Basebord & vbCrLf & “[Basebord]” & vbCrLf
Set objWMIService = GetObject(“winmgmts:” & strComputer & “rootcimv2”)
Set colItems = objWMIService.ExecQuery(“Select * from Win32_BaseBoard”)
For Each objItem in colItems
Basebord = Basebord & “BasebordManufacturer=” & objItem.Manufacturer & vbcrlf
if objItem.Model = “” then
Basebord = Basebord & “BasebordModel=” & objItem.Model & vbcrlf
Else
Basebord = Basebord & “BasebordModel=” & vbcrlf
end if
Basebord = Basebord & “BasebordProduct=” & objItem.Product & vbcrlf
Basebord = Basebord & “BasebordSerialNumber=” & objItem.SerialNumber & vbcrlf
Next
‘ Collect Drivers info
disk = disk & vbCrLf & “[Disk]” & vbCrLf
Set colItems = objWMIService.ExecQuery (“Select * from Win32_LogicalDisk”)
For Each objItem in colItems
if objItem.Name = “” Then disk = disk & “DiskName=” else disk = disk & “DiskName=” & objItem.Name & vbCrlf
if objItem.Description = “” Then disk = disk & “DiskDesc=” else disk = disk & “DiskDesc=” & objItem.Description & vbCrlf
if objItem.VolumeName = “” Then disk = disk & “DiskVolumeName=” & vbcrlf else disk = disk & “DiskVolumeName=” & objItem.VolumeName & vbCrlf
if objItem.VolumeSerialNumber = “” then disk = disk & “DiskVolumeSerialNumber=” else disk = disk & “DiskVolumeSerialNumber=” & objItem.VolumeSerialNumber & vbCrlf
if objItem.Size =”” then disk = disk & “DiskTotalSize=” else disk = disk & “DiskTotalSize=” & Int(objItem.Size /1073741824) & vbCrlf
if objItem.FreeSpace = “” Then disk = disk & “DiskFreeSize=” else disk = disk & “DiskFreeSize=” & Int(objItem.FreeSpace /1073741824) & vbCrlf & vbCrlf
Next
‘ Collect Modems info
modem = modem & vbCrLf & “[Modem]” & vbCrLf
Set colItems = objWMIService.ExecQuery(“Select * from Win32_POTSModem”)
For Each objItem in colItems
modem = modem & “ModemAttachedTo=” & objItem.AttachedTo & vbcrlf
modem = modem & “ModemDeviceType=” & objItem.DeviceType & vbcrlf
modem = modem & “ModemModel=” & objItem.Model & vbcrlf & vbcrlf
Next
‘ Collect Network Cards info
Networkb = Networkb & vbCrLf & “[Network]” & vbCrLf
Set colItems = objWMIService.ExecQuery(“SELECT * FROM Win32_NetworkAdapterConfiguration”)
For Each objItem In colItems
For Each objValue In objItem.IPAddress
If objValue <> “” Then
Networkb = Networkb & “NetworkDescription=” & objItem.Description & vbcrlf &”NetworkIP=” & objValue & vbcrlf & “NetworkMac=” & objItem.MACAddress & vbcrlf
End If
Next
Next
‘ Collect Installed Apps
Apps = Apps & vbCrLf & “[Apps]” & vbCrLf
If colSoftware.Count > 0 Then
For Each objSoftware in colSoftware
Apps = Apps & “Apps=” & Trim(objSoftware.Caption) & vbtab & “,AppsVersion=” & objSoftware.Version & vbCrLf
Next
End If
‘ Collect Services info
Set cInstances = GetObject(“winmgmts:{impersonationLevel=impersonate}//” &_
strComputer & “/root/cimv2:Win32_Service”).Instances_
svrc = svrc & vbCrLf & “[Services]” & vbCrLf
For Each oInstance In cInstances
svrc= svrc & “Services=” & oInstance.Properties_(“DisplayName”).Value & “,” & oInstance.Properties_(“StartMode”).Value & “,” & oInstance.Properties_(“State”).Value & vbCrLf
Next
‘ Collect Installed Microsft Updates
Updates = Updates & vbCrLf & “[Updates]” & vbCrLf
Set objSession = CreateObject(“Microsoft.Update.Session”, strComputer)
If Err.Number <> 0 Then
Set objSearcher = objSession.CreateUpdateSearcher
intHistoryCount = objSearcher.GetTotalHistoryCount
Set colHistory = objSearcher.QueryHistory(1, intHistoryCount)
For Each objEntry in colHistory
Set objIdentity = objEntry.UpdateIdentity
UPDT = day(objEntry.Date) & “.” & month(objEntry.Date) & “.” & year(objEntry.Date) & CStr(Right(objEntry.Date,9))
Updates = Updates & “UpdateDate=” & UPDT & “,” & “UpdateTitle=” & objEntry.Title & vbcrlf
Next
End If
Report = ComputerInfo & LocalAdminGroup & OsInfo & Cpu & Bios & Basebord & Disk & Modem & Networkb & Apps & svrc & Updates
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objTextFile = objFSO.CreateTextFile( filename , True)
objTextFile.WriteLine Report
objTextFile.Close
Set FSO =CreateObject(“scripting.FileSystemObject”)
if FSO.FileExists (filename) then
FSO.CopyFile filename ,Targetpath , True
end if
SET objWMIDateTime = Nothing
SET objWMI = Nothing
SET colOS = Nothing
Set objWMIService = Nothing
Set colChassis = Nothing
Set dtmInstallDate = Nothing
Set colOperatingSystems = Nothing
Set colSoftware = Nothing
Set objNetwork = Nothing
Set objComp = Nothing
Set colSettings = Nothing
Set colItems = Nothing
Set colBIOS = Nothing
Set objFSO = Nothing
Set objTextFile = Nothing
Set FSO = Nothing
Set objSearcher = Nothing
Set colHistory = Nothing
Set objIdentity = Nothing
FUNCTION TimeSpan(dt1, dt2)
IF (ISDATE(dt1) AND ISDATE(dt2)) = FALSE THEN
TimeSpan = “00:00:00”
EXIT FUNCTION
END IF
seconds = ABS(DATEDIFF(“S”, dt1, dt2))
minutes = seconds 60
hours = minutes 60
minutes = minutes MOD 60
seconds = seconds MOD 60
IF LEN(hours) = 1 THEN hours = “0” & hours
TimeSpan = hours & “:” & _
RIGHT(“00” & minutes, 2) & “:” & _
RIGHT(“00” & seconds, 2)
END FUNCTION