22. juni 2004 - 10:02Der er
8 kommentarer og 1 løsning
.bat fil der kan lave en list over installeret programmer
Er det muligt at lave en batch fil der kan udskrive en list over installeret programmer på en pc og sende filen til en LAN adr.
Jeg skal finde frem til hvilke programmer mine medarbejder har installeret på Deres PC'er, så vi kan finde frem til at alle vores licenser er i orden. Og jeg gider ikke rende rundt og skrive det op for hver enkelt, så jeg tænkte at man måske kunne lave et script der kunne hjælpe mig.
en liste/dir af C:\Programmer er egentlig ok, men jeg ville gerne have versions nummere med.
Jeg forstiller mig noget i stil med, men jeg er lidt i tvivl:
@echo off net use x: \\192.168.1.2\reg1 dir > listpc1.txt xcopy "c:\programmer\listpc1.txt" x:\ /y /e net use x: /delete echo Registrering udført pause > null
Her er VBS script som laver en list over alle installerede programmer på PC. Script skriver ogsp navn etc. på PC i tekst fil. Tekst fil bliver lagt på bruger PC, på C:\. Du kan evt. rette i script, så script køres fra server eller fra PC og ligger fil på din server... Håber at du/I kan bruge det. Gem nedenstående som FILNAVN.VBS.
Mvh.
Brandmanden
'====================================================================================================================== 'Filnavn...........: List_Software.vbs 'Beskrivelse.......: Listning af installerede applikationer '======================================================================================================================
'Hovedobjekter Dim WshShell, FSO, WshNetwork, WMIService
'Info fra Win32_OperatingSystem Dim sOSCaption, sCSDVersion, sOSLanguage, sVersion
'Info fra Win32_Bios Dim sSerialNumber
'Info fra Win32_ComputerSystem Dim sManufacturer, sModel
'Info fra Windows Installer Dim sMSIVersion, aMSIApps, aMSIAppInstDate
'Info fra registry om andre applikationer Dim aOtherApps
'Andre variabler Dim sServerName, sUserName, sTempPath
'Erklæringer Set WshShell = WScript.CreateObject("WScript.Shell") Set FSO = WScript.CreateObject("Scripting.FileSystemObject") Set WshNetwork = WScript.CreateObject("WScript.Network")
If CheckOS Then Set WMIService = GetObject("winmgmts:\\" & sServerName & "\root\cimv2") GetFileNames Set WMIService = Nothing Else WshShell.Popup "Dette værktøj kan kun benyttes på Windows 2000 eller senere.", 7, "Spiritech - Systeminfo", _ vbOKOnly + vbExclamation + vbSystemModal End If
'Oprydning Set WshNetwork = Nothing Set FSO = Nothing Set WshShell = Nothing
Function CheckOS Dim sOSVersion, sRegValue sOSVersion = WshShell.Environment("PROCESS")("OS") CheckOS = False If sOSVersion = "Windows_NT" Then sRegValue = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion") Select Case sRegValue Case "5.0" CheckOS = True Case "5.1" CheckOS = True End Select End If End Function
Sub GetFileNames Dim sFileName, iAnswer GetSystemInfo GetMSIApps GetOtherApps sFileName = sTempPath & sServerName & ".txt" If FSO.FileExists(sFileName) Then FSO.DeleteFile sFileName, True WriteToTDF sFileName ' WshShell.Run "notepad.exe " & sFileName, 1, True ' FSO.DeleteFile sFileName End Sub
Sub GetSystemInfo Dim oMember, i, iArraySize
Dim wmiOperatingSystemSet Set wmiOperatingSystemSet = WMIService.ExecQuery("select * from Win32_OperatingSystem") For Each oMember In wmiOperatingSystemSet With oMember sOSCaption = .Caption sCSDVersion = .CSDVersion If sCSDVersion = "" Then sCSDVersion = "Ingen" sOSLanguage = .OSLanguage Select Case sOSLanguage Case "1033" sOSLanguage = "English" Case "1030" sOSLanguage = "Dansk" Case Else sOSLanguage = "Unkendt!" End Select sVersion = .Version End With Next Set wmiOperatingSystemSet = Nothing
Dim wmiBiosSet Set wmiBiosSet = WMIService.ExecQuery("select * from Win32_Bios") For Each oMember In wmiBiosSet sSerialNumber = oMember.SerialNumber Next Set wmiBiosSet = Nothing
Dim wmiComputerSystemSet Set wmiComputerSystemSet = WMIService.ExecQuery("select * from Win32_ComputerSystem") For Each oMember In wmiComputerSystemSet With oMember sManufacturer = .Manufacturer sModel = .Model End With Next Set wmiComputerSystemSet = Nothing End Sub
Sub GetMSIApps Dim MSIObj, oProductSet, iArraySize, i, sProduct, k, l, sTemp Set MSIObj = Wscript.CreateObject("WindowsInstaller.Installer") If IsObject(MSIObj) Then sMSIVersion = MSIObj.Version Set oProductSet = MSIObj.Products iArraySize = oProductSet.Count - 1 ReDim aMSIApps(iArraySize) ReDim aMSIAppInstDate(iArraySize) i = 0 For Each sProduct In oProductSet aMSIApps(i) = MSIObj.ProductInfo(sProduct, "ProductName") sTemp = MSIObj.ProductInfo(sProduct, "InstallDate") aMSIAppInstDate(i) = Right(sTemp, 2) & "-" & Mid(sTemp, 5, 2) & "-" & Left(sTemp, 4) i = i + 1 Next For k = 0 To iArraySize - 1 For l = k + 1 To iArraySize If LCase(aMSIApps(l)) < LCase(aMSIApps(k)) Then sTemp = aMSIApps(l) aMSIApps(l) = aMSIApps(k) aMSIApps(k) = sTemp sTemp = aMSIAppInstDate(l) aMSIAppInstDate(l) = aMSIAppInstDate(k) aMSIAppInstDate(k) = sTemp End If Next Next Set oProductSet = Nothing Else sMSIVersion = "Ikke installeret" ReDim aMSIApps(0) aMSIApps(0) = "N/A" ReDim aMSIAppInstDate(0) aMSIAppInstDate(0) = "N/A" End If Set MSIObj = Nothing End Sub
Sub GetOtherApps Const sMainKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Const hDefKey = &H80000002 Dim oRegistry, sKeys, i, j, k, l, bKeyOK, sVal1, sVal2, iArraySize, sTemp Set oRegistry = GetObject("winmgmts:\\" & sServerName & "\root\default:StdRegProv") If IsObject(oRegistry) Then oRegistry.EnumKey hDefKey, sMainKey, sKeys iArraySize = 0 If IsArray(sKeys) Then For i = 0 To UBound(sKeys) bKeyOK = True If Left(sKeys(i), 1) = "{" And Right(sKeys(i), 1) = "}" Then bKeyOK = False If Left(sKeys(i), 1) = "Q" And Len(sKeys(i)) = 7 Then bKeyOK = False If bKeyOK Then sVal1 = "HKEY_LOCAL_MACHINE\" & sMainKey & "\" & sKeys(i) & "\DisplayName" sVal2 = "HKEY_LOCAL_MACHINE\" & sMainKey & "\" & sKeys(i) & "\QuietDisplayName" If ExistValue(sVal1) Or ExistValue(sVal2) Then iArraySize = iArraySize + 1 End If Next iArraySize = iArraySize - 1 ReDim aOtherApps(iArraySize) j = 0 For i = 0 To UBound(sKeys) bKeyOK = True If Left(sKeys(i), 1) = "{" And Right(sKeys(i), 1) = "}" Then bKeyOK = False If Left(sKeys(i), 1) = "Q" And Len(sKeys(i)) = 7 Then bKeyOK = False If bKeyOK Then sVal1 = "HKEY_LOCAL_MACHINE\" & sMainKey & "\" & sKeys(i) & "\DisplayName" sVal2 = "HKEY_LOCAL_MACHINE\" & sMainKey & "\" & sKeys(i) & "\QuietDisplayName" If ExistValue(sVal1) Then aOtherApps(j) = WshShell.RegRead(sVal1) j = j + 1 ElseIf ExistValue(sVal2) Then aOtherApps(j) = WshShell.RegRead(sVal2) j = j + 1 End If End If Next For k = 0 To iArraySize - 1 For l = k + 1 To iArraySize If LCase(aOtherApps(l)) < LCase(aOtherApps(k)) Then sTemp = aOtherApps(l) aOtherApps(l) = aOtherApps(k) aOtherApps(k) = sTemp End If Next Next Else ReDim aOtherApps(0) aOtherApps(0) = "N/A" End If Else ReDim aOtherApps(0) aOtherApps(0) = "Kun tilgængelig i Windows 2000 eller senere" End If Set oRegistry = Nothing End Sub
Function ExistValue(value) Dim sVal On Error Resume Next sVal = WshShell.RegRead(value) If Err.Description = Empty Then ExistValue = True Else ExistValue = False End If End Function
Sub WriteToTDF(sFileName) Dim oTDFFile, i, iArraySize Set oTDFFile = FSO.OpenTextFile(sFileName, ForWriting, True)
Jeg har allerede haft meget nytte af dit program... men på nogle maskiner win2000 får jeg en fejl i linje 36: klasse farbrik ej fundet... hvad kan det skyldes..?
Set WshShell = WScript.CreateObject("WScript.Shell")
??? Ja, hvor mange maskiner er det du får denne fejl på? Laver disse intet, nej, det gør de ikke... måske der mangler et eller andet i disse maskiners OS ??? //Brandmand
Kigger på det... arbejder ikke med IT mere, så jeg har ikke en W3K server hvor jeg kan teste på. Hvilken fejl får du?
Måske du kan bruge dette script. Det oplyser godt nok ikke omkring inst. progs...
' COMMENT: Automatisk System Dokumentation '
'========================================================================== Set Network = Wscript.CreateObject("Wscript.Network") Set Fs = CreateObject("Scripting.FileSystemObject") Set FSO = CreateObject("Scripting.FileSystemObject") Set Shell = Wscript.CreateObject("Wscript.Shell")
Set BiosSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_Bios") For Each member in BiosSet StrSerialNumber = member.SerialNumber next Set ComputerSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_ComputerSystem") for each member in ComputerSet StrManufacturer = member.Manufacturer StrModel = member.Model next File.writeline "<center><Table border=0 cellpadding=0 cellspacing=0 width=85%>" File.writeline "<TD width=7%><P align=left>1.1</TD><TD width=30%><P align=left><font Style='font:12pt Tahoma'><b>Hardware overblik</b></font></TD></TR>" File.writeline "<TD width=7%></TD><TD> </TD></TR></p>" File.writeline "<TD width=7%></TD><TD>Computer : </TD><TD>" & StrManufacturer& " " & StrModel & "</TD></TR><br>" File.writeline "<TD width=7%></TD><TD>Serie Nummer : </TD><TD>" & StrSerialNumber & "</TD></TR>" File.writeline "<TD width=7%></TD><TD> </TD><TD> </TD></TR>" Set CPUSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_Processor") for each member in CPUSet StrCPUName = member.Name StrCPUCurrentClockSpeed = member.CurrentClockSpeed StrCPUExtClock = member.ExtClock StrCPUL2CacheSize = member.L2CacheSize File.writeline "<TD width=7%></TD><TD>Processor : </TD><TD>" & StrCPUName & " " & StrCPUCurrentClockSpeed & "/" & StrCPUExtClock & " MHz, " & StrCPUL2CacheSize & " Kb Cache" & "</TD></TR>" next Set LogicalMemoryConfigurationSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_LogicalMemoryConfiguration") for each member in LogicalMemoryConfigurationSet StrTotalPhysicalMemory = Int(member.TotalPhysicalMemory / 1024)+ 1 & " MB" Next File.writeline "<TD width=7%></TD><TD>Ram : </TD><TD>" & StrTotalPhysicalMemory & "</TD></TR>" Set DiskDriveSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_DiskDrive") for each member in DiskDriveSet StrCaption = member.Caption File.writeline "<TD width=7%></TD><TD>Harddisk : </TD><TD>" & StrCaption & "</TD></TR>" next Set NetworkAdapterSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_NetworkAdapter where ((Manufacturer <> 'Microsoft') AND (MACAddress Is Not NULL))") for each member in NetworkAdapterSet StrDescription = member.Description File.writeline "<TD width=7%></TD><TD>Netkort : </TD><TD>" & StrDescription & "</TD></TR>" next Set TapeSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_TapeDrive") for each member in TapeSet StrTapeCaption = member.Caption File.writeline "<TD width=7%></TD><TD>Tape Streamer : </TD><TD>" & StrTapeCaption & "</TD></TR>" next Set CdromSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_CDROMDrive") for each member in CDromSet StrcdromCaption = member.Caption File.writeline "<TD width=7%></TD><TD>CD-Rom Drev : </TD><TD>" & StrcdromCaption & "</TD></TR>" next Set POTSModemSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_POTSModem") for each member in POTSModemSet StrCaption = member.Caption File.writeline "<TD width=7%></TD><TD>Modem : </TD><TD>" & StrCaption & "</TD></TR>" next Set SCSISet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_SCSIController") for each member in SCSISet StrSCSICaption = member.Caption File.writeline "<TD width=7%></TD><TD>SCSI Kontroller : </TD><TD>" & StrSCSICaption & "</TD></TR>" next Set DisplayConfigurationSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_DisplayConfiguration") for each member in DisplayConfigurationSet StrCaption = member.Caption File.writeline "<TD width=7%></TD><TD>Skærmkort : </TD><TD>" & StrCaption & "</TD></TR>" next Set DesktopMonitorSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_DesktopMonitor") for each member in DesktopMonitorSet StrCaption = member.Caption File.writeline "<TD width=7%></TD><TD>Skærm : </TD><TD>" & StrCaption & "</TD></TR>" next
File.writeline "</Table></p></center>"
' 2 Operativsystem overblik
Set ComputerSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_ComputerSystem") for each member in ComputerSet StrDomain = member.Domain StrDomainRole = member.DomainRole Select Case StrDomainRole Case "0" StrDomainRole = "Standalone Workstation" Case "1" StrDomainRole = "Member Workstation" Case "2" StrDomainRole = "Standalone Server" Case "3" StrDomainRole = "Member Server" Case "4" StrDomainRole = "Backup Domain Controller" Case "5" StrDomainRole = "Primary Domain Controller" Case Else StrDomainRole = "Kender ikke typen !" End Select next
Set OperatingSystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_OperatingSystem") for each member in OperatingSystemSet StrCaption = member.Caption StrBuildNumber = member.BuildNumber StrBuildType = member.BuildType StrCSDVersion = member.CSDVersion StrDistributed = member.Distributed Select Case StrDistributed Case "True" StrDistributed = "Ja" Case "False" StrDistributed = "Nej" Case Else StrDistributed = "" End Select StrForegroundApplicationBoost = member.ForegroundApplicationBoost Select Case StrForegroundApplicationBoost Case "0" StrForegroundApplicationBoost = "Ingen" Case "1" StrForegroundApplicationBoost = "Minimum" Case "2" StrForegroundApplicationBoost = "Maximum" Case Else StrForegroundApplicationBoost = "Unknovn" End Select StrFreePhysicalMemory = member.FreePhysicalMemory StrFreeSpaceInPagingFiles = member.FreeSpaceInPagingFiles StrFreeVirtualMemory = member.FreeVirtualMemory StrInstallDate = member.InstallDate StrInstallYear = Left(StrInstallDate,4) StrInstallMD = Mid(StrInstallDate, 5, 2) StrInstallDD = Mid(StrInstallDate, 7, 2) StrLastBootUpTime = member.LastBootUpTime StrLastBootUpTimeYear = Left(StrLastBootUpTime, 4) StrLastBootUpTimeMD = Mid(StrLastBootUpTime, 5, 2) StrLastBootUpTimeDD = Mid(StrLastBootUpTime, 7, 2) StrLocale = member.Locale StrMaxNumberOfProcesses = member.MaxNumberOfProcesses StrMaxProcessMemorySize = Int(member.MaxProcessMemorySize / 1024) & " MB" StrNumberOfLicensedUsers = member.NumberOfLicensedUsers StrNumberOfProcesses = member.NumberOfProcesses StrNumberOfUsers = member.NumberOfUsers StrOrganization = member.Organization StrOSLanguage = member.OSLanguage Select Case StrOSLanguage Case "1033" StrOSLanguage = "Engelsk" Case "1030" StrOSLanguage = "Dansk" Case Else StrOSLanguage = "Ukendt" End Select StrOSProductSuite = member.OSProductSuite Select Case StrOSProductSuite Case "Null" StrOSProductSuite = "Ukendt (Måske Professional)" Case "1" StrOSProductSuite = "Small Business" Case "2" StrOSProductSuite = "Enterprise" Case "4" StrOSProductSuite = "BackOffice" Case "8" StrOSProductSuite = "Commication Server" Case "16" StrOSProductSuite = "Terminal Server" Case "32" StrOSProductSuite = "Small Business (Restricted)" Case "64" StrOSProductSuite = "Embedded NT" Case "128" StrOSProductSuite = "Data Center" Case Else StrOSProductSuite = "" End Select StrRegisteredUser = member.RegisteredUser StrServicePackMajorVersion = member.ServicePackMajorVersion StrServicePackMinorVersion = member.ServicePackMinorVersion StrStatus = member.Status StrVersion = member.Version StrWindowsDirectory = member.WindowsDirectory next
Set QuickFixEngineeringSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_QuickFixEngineering") for each member in QuickFixEngineeringSet StrHotFixID = StrHotFixID & member.HotFixID & " "
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.