DB2 ist ein Produkt der
IBM Corporation. Bitte Copyright- und Trademark-Hinweise beachten!
'-----------------------------------------------------------------------------
'- DB2Inst.vbs - Display DB2 Install Information
'-----------------------------------------------------------------------------
'- Arguments .....:
'- Calls .........: NOTEPAD.EXE to display data
'-----------------------------------------------------------------------------
'- Requires ......: - Windows Scripting Shell 5.6 or higher
'- - IBM DB2 ADO Support 2.8 or higher
'- - IBM DB2 Run Time Client V8.2 or higher
'- - IBM DB2 Database Server V8.2 FixPak 9 or higher
'- Changes .......: First release 29.07.2005/GR
'- 02.08.2005/GR : V1.1 Excessive data volume, method to present data
'- changed from sendkeys/notepad to fso/notepad
'-----------------------------------------------------------------------------
Option Explicit
'On Error Resume Next
'--- Constants ---------------------------------------------------------------
Const ConstComputer = "."
Const conScriptVersion = "1.0"
Const constForReading = 1
Const constForWriting = 2
'--- Variables ---------------------------------------------------------------
Dim objShell'Object Shell
Dim objExec'Object Exec external program
Dim objRun'Object Run external program
Dim objArgs'Object Arguments
Dim objEnv'Object Environment
Dim objWMIService 'Object WMI Service
Dim objSoftware 'Object Software
Dim strWSHVersion'WSH Version
Dim strScriptName'Script Name
Dim strScriptFullName'Full Script Name
Dim strCurrDir'Current Directory
Dim objCon 'connection Object
Dim objFSO'File System Object
Dim objF'File Object
Dim colSoftware'Software Collection
Dim strSQLStmt'SQL Statement
Dim arrData'Output Data
Dim datTimestamp'current date/time
Dim strTempPath'Name of system /temp path
Dim strOutputFile'Full Name of output file
Dim Software'Software
Dim intWork
Dim strWork
'--- Retrieve Script Information ---------------------------------------------
Set objShell = WScript.CreateObject("Wscript.Shell")
Set objEnv= objShell.Environment("USER")'Environment type
strTempPath= objEnv("TEMP")'Environment variable
strWSHVersion = Wscript.Version
strScriptName = Wscript.ScriptName
strScriptFullName =WScript.ScriptFullname
strCurrDir= objShell.CurrentDirectory
strOutputFile= strTempPath & "\" & left(strScriptName,len(strScriptName)-4) & "-" & FormatDateTime(Date,0)
if strWSHVersion <> "5.6" then
MsgBox "This script requires WSH Version 5. or higher!" , _
16, _
"Display DB2 Installation Information - " & strScriptFullName
Wscript.Quit
end if
'--- Set Link on Desktop ----------------------------------------------------
SetLink
'--- Open Output File to write collected information on ----------------------
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objF = objFSO.OpenTextFile(strOutputFile, constForWriting, True)
datTimestamp = now
'--- Determine Installed Software --------------------------------------------
objF.WriteLine "-------------------------------------------------------------------------------------"
objF.WriteLine strScriptFullName & " Version " & conScriptVersion & " - display installed DB2 Software information"
objF.WriteLine "-------------------------------------------------------------------------------------"
objF.WriteBlankLines(1)
WMI_InstalledSoftware
objF.WriteBlankLines(1)
objF.WriteLine "File "& strOutputFile & " created at " & datTimestamp
'--- Open NOTEPAD to view collected information on ---------------------------
'set objExec = objShell.Exec("notepad.exe")
objShell.Run "%windir%\notepad " & strOutputFile,1
'WScript.Sleep 100
'objShell.AppActivate "Editor"
'WScript.Sleep 100
Wscript.Quit
'#############################################################################
'# WMI_InstalledSoftware: List installed Software
'#############################################################################
Sub WMI_InstalledSoftware()
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& constComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product where caption like '%DB2%' or description like '%DB2%'")
For Each objSoftware in colSoftware
objF.WriteLine "---------------------------------------------------"
objF.WriteLine "Caption .........: " & objSoftware.Caption
objF.WriteLine "Description .....: " & objSoftware.Description
objF.WriteLine "Name ............: " & objSoftware.name
objF.WriteLine "Version ........: " & objSoftware.Version
objF.WriteLine "Vendor ..........: " & objSoftware.Vendor
objF.WriteLine "ID Number .......: " & objSoftware.IdentifyingNumber
objF.WriteLine "Install Date ....: " & objSoftware.InstallDate2
objF.WriteLine "Install Location : " & objSoftware.InstallLocation
objF.WriteLine "Install State ...: " & objSoftware.InstallState
objF.WriteLine "Package Cache ...: " & objSoftware.PackageCache
objF.WriteLine "SKU Number ......: " & objSoftware.SKUNumber
Next
End Sub
'#############################################################################
'# SetLink: Sets link to this script on Desktop
'#############################################################################
Sub SetLink()
Dim strDesktop
Dim oShellLink
strDesktop = objShell.SpecialFolders("Desktop")
set oShellLink = objShell.CreateShortcut(strDesktop & "\Display DB2 Install Infos.lnk")
oShellLink.TargetPath = left(strScriptFullName,len(strScriptFullName)-3) & "wsh"
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+S"
oShellLink.IconLocation = "wscript.exe, 0"
oShellLink.Description = "Snapshot.vbs - Display DB2 Install Infos"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save
End Sub
© Gernot Ruban