Hello All,
For some time I have been using a script that determines the OS type then runs the correct code for the OS. I now need to deploy several updates that are Service Pack specific. The updates I need to deploy for example: Update 1 can run if 2k has sp3 or better, if the service pack is less then sp3 then a supporting file needs to be ran prior to running update 1. I will be working with 98, 2k, XP, 2003. Here is an example of the script I have.
------------------------------------------------------
'========= Declarations =================
Option Explicit
'Define variables
Dim sMessage
Dim sOStype
Dim sComputerRole
Dim iRetVal
Dim Mbox
Dim objEnv
Dim WshShell
'========= Main code =================
'Display a string for OS type rather than a number
iRetVal = GetOSType
Select Case iRetVal
Case 0
sOStype = "Not found"
Case 1
sOStype = "Windows 95"
Case 2
sOStype = "Windows 98"
Case 3
sOStype = "Windows Me"
Case 4
sOStype = "Windows NT"
Case 5
sOStype = "Windows 2000"
Case 6
sOStype = "Windows XP"
End Select
'Construct the info we want to show
'sMessage = sOStype & vbCr
'Display to screen
'Call MsgBox(sMessage, vbOkOnly, "OS info")
Mbox = MsgBox("Pilot VNC Install", 4, "Do you wish to install VNC ?")
If Mbox = 7 Then
WScript.Quit
End If
'Promt user about need to use District Image
Set WshShell = WScript.CreateObject("WScript.Shell")
'Set objEnv = WshShell.Environment("System")
'WScript.echo GetOSType
If GetOSType = 6 Then
WshShell.Run "SetupFiles\PilotVNC-XpSetup.exe"
Else
If GetOSType = 5 Then
WshShell.Run "SetupFiles\PilotVNC-Win2kSetup.exe"
Else
MsgBox("This is not a valid Operating System.")
End If
End If
'========= Procedures and functions ==============
Function GetOSType
'Version 1.3
'1.2 - 1.3 Renamed object variables
'1.1 - 1.2 Supports Win XP
'1.0 - 1.1 Functions now returns 0 when OS info is not found.
'Returns a integer indicating the operating system.
'Note: Win 3.11, Win NT 3.5 and Win NT 3.51 does not run WSH scripts.
'0 = Not able to find OS Type
'1 = Windows 95
'2 = Windows 98
'3 = Windows Me
'4 = Windows NT 4.0
'5 = Windows 2000
'6 = Windows XP
'Declare local variables
Dim sOStype 'Temp variable to store values from registry
Dim oWshShell 'Needs the Shell object to access registry
'Initialize
Set oWshShell = WScript.CreateObject("WScript.Shell")
GetOSType = 0
'Get OS Info from registry
On Error Resume Next
'Initially assume Win9x platform
sOStype = oWshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Version")
If sOStype = Empty Then
'If variable still empty then NT platform is used
'Read version from registry to find type of NT platform
' "CurrentVersion"="4.0"
' "CurrentVersion"="5.0"
sOStype = Trim(oWshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion"))
If sOStype = "5.1" Then
'Windows XP
GetOSType = 6
ElseIf sOStype = "5.0" Then
'Windows 2000
GetOSType = 5
ElseIf sOStype = "4.0" Then
'Windows NT 4.0
GetOSType = 4
End If
Else
'Find type of Win9x platform
' "Version"="Windows 98"
' "Version"="Windows 95"
' "Version"="Windows Millennium Edition"
If InStr(1,sOStype,"Millennium Edition",1) > 0 Then
'Windows Me
GetOSType = 3
ElseIf InStr(1,sOStype,"98",0) > 0 Then
'Windows 98
GetOSType = 2
ElseIf InStr(1,sOStype,"95",0) > 0 Then
'Windows 95
GetOSType = 1
End If
End If
On Error GoTo 0
'Clean up
Set oWshShell = Nothing
End Function
For some time I have been using a script that determines the OS type then runs the correct code for the OS. I now need to deploy several updates that are Service Pack specific. The updates I need to deploy for example: Update 1 can run if 2k has sp3 or better, if the service pack is less then sp3 then a supporting file needs to be ran prior to running update 1. I will be working with 98, 2k, XP, 2003. Here is an example of the script I have.
------------------------------------------------------
'========= Declarations =================
Option Explicit
'Define variables
Dim sMessage
Dim sOStype
Dim sComputerRole
Dim iRetVal
Dim Mbox
Dim objEnv
Dim WshShell
'========= Main code =================
'Display a string for OS type rather than a number
iRetVal = GetOSType
Select Case iRetVal
Case 0
sOStype = "Not found"
Case 1
sOStype = "Windows 95"
Case 2
sOStype = "Windows 98"
Case 3
sOStype = "Windows Me"
Case 4
sOStype = "Windows NT"
Case 5
sOStype = "Windows 2000"
Case 6
sOStype = "Windows XP"
End Select
'Construct the info we want to show
'sMessage = sOStype & vbCr
'Display to screen
'Call MsgBox(sMessage, vbOkOnly, "OS info")
Mbox = MsgBox("Pilot VNC Install", 4, "Do you wish to install VNC ?")
If Mbox = 7 Then
WScript.Quit
End If
'Promt user about need to use District Image
Set WshShell = WScript.CreateObject("WScript.Shell")
'Set objEnv = WshShell.Environment("System")
'WScript.echo GetOSType
If GetOSType = 6 Then
WshShell.Run "SetupFiles\PilotVNC-XpSetup.exe"
Else
If GetOSType = 5 Then
WshShell.Run "SetupFiles\PilotVNC-Win2kSetup.exe"
Else
MsgBox("This is not a valid Operating System.")
End If
End If
'========= Procedures and functions ==============
Function GetOSType
'Version 1.3
'1.2 - 1.3 Renamed object variables
'1.1 - 1.2 Supports Win XP
'1.0 - 1.1 Functions now returns 0 when OS info is not found.
'Returns a integer indicating the operating system.
'Note: Win 3.11, Win NT 3.5 and Win NT 3.51 does not run WSH scripts.
'0 = Not able to find OS Type
'1 = Windows 95
'2 = Windows 98
'3 = Windows Me
'4 = Windows NT 4.0
'5 = Windows 2000
'6 = Windows XP
'Declare local variables
Dim sOStype 'Temp variable to store values from registry
Dim oWshShell 'Needs the Shell object to access registry
'Initialize
Set oWshShell = WScript.CreateObject("WScript.Shell")
GetOSType = 0
'Get OS Info from registry
On Error Resume Next
'Initially assume Win9x platform
sOStype = oWshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Version")
If sOStype = Empty Then
'If variable still empty then NT platform is used
'Read version from registry to find type of NT platform
' "CurrentVersion"="4.0"
' "CurrentVersion"="5.0"
sOStype = Trim(oWshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion"))
If sOStype = "5.1" Then
'Windows XP
GetOSType = 6
ElseIf sOStype = "5.0" Then
'Windows 2000
GetOSType = 5
ElseIf sOStype = "4.0" Then
'Windows NT 4.0
GetOSType = 4
End If
Else
'Find type of Win9x platform
' "Version"="Windows 98"
' "Version"="Windows 95"
' "Version"="Windows Millennium Edition"
If InStr(1,sOStype,"Millennium Edition",1) > 0 Then
'Windows Me
GetOSType = 3
ElseIf InStr(1,sOStype,"98",0) > 0 Then
'Windows 98
GetOSType = 2
ElseIf InStr(1,sOStype,"95",0) > 0 Then
'Windows 95
GetOSType = 1
End If
End If
On Error GoTo 0
'Clean up
Set oWshShell = Nothing
End Function