02. marts 2006 - 21:40
Der er
2 kommentarer og
1 løsning
Skal finde Bruger, IBM Serial nummer, IBM type nummer og PC navn
Hi programmerings hajer
Jeg står over for et problem.
Jeg skal finde hvem der er ejer af de pcer som er i vores firma. Jeg er ny i firmaet og jeg har nu fået til opgave at finde ud af hvem der "ejer" pc'erne ved hjælp af IBM Serial nummer, IBM type nummer og PC navn. Det skal være i VBS da det skal køre i logonscriptet. Det skal kunne skrive et en fil med brugernavnet som filnavn.
Det som jeg har er AD, hvor jeg har computernavnet. Det er faktisk det eneste. det er ca 400 brugere. Derfor skal jeg bruge IBM Serial nummer, IBM type nummer og PC navn til at identifiserer brugeren.
Håber i forstår mit problem
04. marts 2006 - 12:00
#2
Nååååå men jeg fandt selv ud af det...... Tak for hjælpen... :O(
Her får i mit reslutat:
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strComputer,"\root\cimv2",strUserName,strPassword)
Set objRegLocator = CreateObject("WbemScripting.SWbemLocator")
Set objRegService = objRegLocator.ConnectServer(strComputer,"\root\default",strUserName,strPassword)
Set oReg = objRegService.Get("StdRegProv")
' Variables for the Win32_ComputerSystem class
'Dim strComputerSystem_Name, strComputerSystem_TotalPhysicalMemory, strComputerSystem_Domain, nComputerSystem_DomainRole
'Dim strTotalPhysicalMemoryMB, strDomainType, strComputerRole
' Variables for the Win32_OperatingSystems Class
'Dim strOperatingSystem_InstallDate, strOperatingSystem_Caption, strOperatingSystem_ServicePack, strOperatingSystem_WindowsDirectory
'Dim strOperatingSystem_LanguageCode
'Get Version and Service pack
Set colItems = objWMIService.ExecQuery("Select Caption, CSDVersion, InstallDate, OSLanguage, Version, WindowsDirectory from Win32_OperatingSystem",,48)
For Each objItem in colItems
strOperatingSystem_InstallDate = objItem.InstallDate
strOperatingSystem_Caption = objItem.Caption
strOperatingSystem_ServicePack = objItem.CSDVersion
strOperatingSystem_LanguageCode = Clng(objItem.OSLanguage)
strOperatingSystem_LanguageCode = Hex(strOperatingSystem_LanguageCode)
nOperatingSystemLevel = objItem.Version
strOperatingSystem_WindowsDirectory = objItem.WindowsDirectory
Next
'Get Vendor, Model and SN
Set colItems = objWMIService.ExecQuery("Select Vendor, Name, IdentifyingNumber from Win32_ComputerSystemProduct",,48)
For Each objItem in colItems
strComputerSystemProduct_Manufacturer = objItem.Vendor
strComputerSystemProduct_Name = objItem.Name
strComputerSystemProduct_IdentifyingNumber = objItem.IdentifyingNumber
Next
'Get Domain, Computername and total mem
Set colItems = objWMIService.ExecQuery("Select Domain, DomainRole, Name, TotalPhysicalMemory from Win32_ComputerSystem",,48)
For Each objItem in colItems
strComputerSystem_Domain = objItem.Domain
nComputerSystem_DomainRole = objItem.DomainRole
strComputerSystem_Name = objItem.Name
strComputerSystem_TotalPhysicalMemory = objItem.TotalPhysicalMemory
strTotalPhysicalMemoryMB = Round(strComputerSystem_TotalPhysicalMemory / 1024 / 1024)
Next
' Get Username and desktop path
Dim strLastUser, strLastUserDomain
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_CURRENT_USER = &H80000001
oReg.GetStringValue HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultUserName", strLastUser
oReg.GetStringValue HKEY_LOCAL_MACHINE,"SYSTEM\CurrentControlSet\Services\lanmanserver\parameters","srvcomment", strFullName
oReg.GetStringValue HKEY_CURRENT_USER,"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Desktop", strUserdesktop
' Write results
'Wscript.echo "Windows Version: " & strOperatingSystem_Caption
'Wscript.echo "Service pack: " & strOperatingSystem_ServicePack
'Wscript.echo "Vandor: " & strComputerSystemProduct_Manufacturer
'Wscript.echo "Model: " & strComputerSystemProduct_Name
'Wscript.echo "Serial number: " & strComputerSystemProduct_IdentifyingNumber
'Wscript.echo "Total Mem: " & strTotalPhysicalMemoryMB
'Wscript.echo "Total Mem: " & strComputerSystem_Domain
'Wscript.echo "Total Mem: " & strComputerSystem_Name
'Wscript.echo "Output file: " & strUserdesktop &"\HWINFO.txt"
'Write to file
Dim objFileSystem, objOutputFile
Dim strOutputFile
'Const OPEN_FILE_FOR_APPENDING = 8
' generate a filename base on the script name
strOutputFile = strUserdesktop &"\HWINFO.txt"
Set objFileSystem = CreateObject("Scripting.fileSystemObject")
'append to file
'Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, OPEN_FILE_FOR_APPENDING)
'Create a file
Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)
' Fill data in file
objOutputFile.WriteLine Now
objOutputFile.WriteLine ""
objOutputFile.WriteLine "FullName: " & strFullName
objOutputFile.WriteLine "Username: " & strLastUser
objOutputFile.WriteLine "Computername: " & strComputerSystem_Name
objOutputFile.WriteLine"Domain: " & strComputerSystem_Domain
objOutputFile.WriteLine ""
objOutputFile.WriteLine "Windows Version: " & strOperatingSystem_Caption
objOutputFile.WriteLine "Service pack: " & strOperatingSystem_ServicePack
objOutputFile.WriteLine "Total Mem: " & strTotalPhysicalMemoryMB & " MB"
objOutputFile.WriteLine ""
objOutputFile.WriteLine "Vandor: " & strComputerSystemProduct_Manufacturer
objOutputFile.WriteLine "Model: " & strComputerSystemProduct_Name
objOutputFile.WriteLine "Serial number: " & strComputerSystemProduct_IdentifyingNumber
objOutputFile.Close
Set objFileSystem = Nothing
Wscript.echo "There has been created a file on your desktop (HWINFO.txt)."
Wscript.echo "Please send this file to nordic_helpdesk@ecolab.com. Its very importent."
Wscript.echo "Thanks Nordic Helpdesk (nordic_helpdesk@ecolab.com)."
WScript.Quit(0)