rono1 Posted December 9, 2005 Posted December 9, 2005 (edited) Could anyone tell me why this script does not progress through the IF and ElseIF statments correctly based on @OSVersion? If I run it on WINNT it executes the install under Win2k and XP so it is not recognizing the OS or my scripting is incorrect. Thanks... IF FileExists(@ProgramFilesDir & "\Sophos\Sophos Anti-Virus\savmain.exe") Then Exit ElseIf @OSVersion = "WIN_XP" Or "WIN_2000" Then RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoInstXP.exe") Run("C:\sophostemp\xpmod.vbs") RunWait('C:\sophostemp\setup.exe -ni') WinKill("InstallShield Wizard", "") ElseIF @OSVersion = "WIN_NT4" Then RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoESNTv1.exe") Run('C:\sophostemp\setup.exe -ni') Else Exit EndIf Exit Edited December 9, 2005 by rono1
seandisanti Posted December 9, 2005 Posted December 9, 2005 Could anyone tell me why this script does not progress through the IF and ElseIF statments correctly based on @OSVersion? If I run it on WINNT it executes the install under Win2k and XP so it is not recognizing the OS or my scripting is incorrect.Thanks...IF FileExists(@ProgramFilesDir & "\Sophos\Sophos Anti-Virus\savmain.exe") Then ExitElseIf @OSVersion = "WIN_XP" Or "WIN_2000" Then RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoInstXP.exe") Run("C:\sophostemp\xpmod.vbs") RunWait('C:\sophostemp\setup.exe -ni') WinKill("InstallShield Wizard", "")ElseIF @OSVersion = "WIN_NT4" Then RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoESNTv1.exe") Run('C:\sophostemp\setup.exe -ni')Else Exit EndIfExitMaybe try using a Select-Case structure instead of the multiway if's
rono1 Posted December 9, 2005 Author Posted December 9, 2005 Maybe try using a Select-Case structure instead of the multiway if'sI am not familiar with select-Case structure...
seandisanti Posted December 9, 2005 Posted December 9, 2005 I am not familiar with select-Case structure... Select Case <expression> statement1 ... [Case statement2 ...][Case Else statementN ...] EndSelectmore details and example available in the help file
rono1 Posted December 9, 2005 Author Posted December 9, 2005 Like this? Select case $var = FileExists(@ProgramFilesDir & "\Sophos\Sophos Anti-Virus\savmain.exe") Then Exit case $var2 = @OSVersion = "WIN_XP" Or "WIN_2000" Then RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoInstXP.exe") Run("C:\sophostemp\xpmod.vbs") RunWait('C:\sophostemp\setup.exe -ni') WinKill("InstallShield Wizard", "") Case $var3 = @OSVersion = "WIN_NT4" Then RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoESNTv1.exe") Run('C:\sophostemp\setup.exe -ni') EndSelect Exit
seandisanti Posted December 9, 2005 Posted December 9, 2005 Like this?Selectcase $var = FileExists(@ProgramFilesDir & "\Sophos\Sophos Anti-Virus\savmain.exe") ThenExitcase $var2 = @OSVersion = "WIN_XP" Or "WIN_2000" ThenRunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir)WinKill("Uninstall", "")RunWait("SoInstXP.exe")Run("C:\sophostemp\xpmod.vbs")RunWait('C:\sophostemp\setup.exe -ni')WinKill("InstallShield Wizard", "")Case $var3 = @OSVersion = "WIN_NT4" ThenRunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir)WinKill("Uninstall", "")RunWait("SoESNTv1.exe")Run('C:\sophostemp\setup.exe -ni')EndSelectExityou don't need the "Then"'s
rono1 Posted December 9, 2005 Author Posted December 9, 2005 I am receiving an error "WARNING: $var1: possibly used before declaration". What do you think is worng? Select Case $var1 = FileExists(@ProgramFilesDir & "\Sophos\Sophos Anti-Virus\savmain.exe") Exit Case $var2 = @OSVersion = "WIN_XP" Or "WIN_2000" RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoInstXP.exe") Run("C:\sophostemp\xpmod.vbs") RunWait('C:\sophostemp\setup.exe -ni') WinKill("InstallShield Wizard", "") Case $var3 = @OSVersion = "WIN_NT4" RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoESNTv1.exe") Run('C:\sophostemp\setup.exe -ni') EndSelect Exit
seandisanti Posted December 9, 2005 Posted December 9, 2005 I am receiving an error "WARNING: $var1: possibly used before declaration". What do you think is worng? Select Case $var1 = FileExists(@ProgramFilesDir & "\Sophos\Sophos Anti-Virus\savmain.exe") Exit Case $var2 = @OSVersion = "WIN_XP" Or "WIN_2000" RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoInstXP.exe") Run("C:\sophostemp\xpmod.vbs") RunWait('C:\sophostemp\setup.exe -ni') WinKill("InstallShield Wizard", "") Case $var3 = @OSVersion = "WIN_NT4" RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoESNTv1.exe") Run('C:\sophostemp\setup.exe -ni') EndSelect Exittry this... if FileExists(@ProgramFilesDir & "\Sophos\Sophos Anti-Virus\savmain.exe") Then Exit $var2 = @OSVersion Select Case $var2 = "WIN_XP" Or $var2 = "WIN_2000" RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoInstXP.exe") Run("C:\sophostemp\xpmod.vbs") RunWait('C:\sophostemp\setup.exe -ni') WinKill("InstallShield Wizard", "") Case $var2 = "WIN_NT4" RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoESNTv1.exe") Run('C:\sophostemp\setup.exe -ni') EndSelect Exit
rono1 Posted December 9, 2005 Author Posted December 9, 2005 try this... if FileExists(@ProgramFilesDir & "\Sophos\Sophos Anti-Virus\savmain.exe") Then Exit $var2 = @OSVersion Select Case $var2 = "WIN_XP" Or $var2 = "WIN_2000" RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoInstXP.exe") Run("C:\sophostemp\xpmod.vbs") RunWait('C:\sophostemp\setup.exe -ni') WinKill("InstallShield Wizard", "") Case $var2 = "WIN_NT4" RunWait('msiexec.exe /X "{99747F0D-D4F8-4877-9CA0-4AE96D963633}" /q', @SystemDir) WinKill("Uninstall", "") RunWait("SoESNTv1.exe") Run('C:\sophostemp\setup.exe -ni') EndSelect Exit Thanks I think its working, now I will try executing it from a network share.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now