Aleksandar Hajduković Posted July 21, 2006 Share Posted July 21, 2006 I am doing some MSI installation and uninstallation and it seems that my script behave very strange - it stops execution unexpectible.What script does? (I commented well all code)It installs one of my InstallShield applications.During setup user choose if want to install Server, Client or Both and this choice is written in registry in values "ServerInstalled" and/or "ClientInstalled".After that step my script STOPS execution :-(It should continue to see if MSDE 2000 is installed (reads from registry key "MSDEInstalled" value "IsInstalled") and if MSDE is not installed and user pick Server installation it installs MSDE and run SQL script to create database.If MSDE is installed and user picked Client installation it must uninstall MSDE and delete registry key "MSDEInstalled".All paths are ok...It seems that somehow that InstallShield application (when I click Finish) close execution of my script (no matter if it is installation or uninstallation)... Maybe parameter /qn is a problem (I didn't want to see question "Do you really want to uninstall?")...Here is my script:expandcollapse popupAutoItSetOption("RunErrorsFatal", 0) ;Read value from registry key to check if SERVER is allready installed (ServerInstalled=1) $serverInstalled = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\SetupChoice", "ServerInstalled") ;Read value from registry key to check if CLIENT is allready installed (ClientInstalled=1) $clientInstalled = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\SetupChoice", "ClientInstalled") ;Read value from registry key to check if MSDE 2000 is installed (MSDEInstalled=1) $msdeInstalled = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\MSDEInstalled", "IsInstalled") ;First -> uninstall Urnik application with GUID {A2925D4F-0905-40DB-AB8D-CB4AA79572B3} if it is allready installed If ($serverInstalled = 1 OR $clientInstalled = 1) Then RunWait(@COMSPEC & " /c " & @SystemDir & "/msiexec /qn /x{A2925D4F-0905-40DB-AB8D-CB4AA79572B3}", "", @SW_HIDE) ;Delete possible remained registry keys to be sure that all is deleted RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\Metronik.Timetable") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\SetupChoice") EndIf ;Second -> install again Urnik application from the beginning (user can choose to install SERVER or CLIENT) ;After installation it will have value "ServerInstalled=1" if he picked SERVER or "ClientInstalled=1" if he picked CLIENT RunWait(@COMSPEC & " /c " & @ScriptDir & "/Urnik/Urnik.exe", "", @SW_HIDE) ;If MSDE is not installed -> install it only if user picked to install SERVER installation If ($msdeInstalled <> 1) Then ;If SERVER is installed -> only then install MSDE 2000 and create DB If ($serverInstalled = 1) Then ;Install MSDE 2000 RunWait(@COMSPEC & " /c " & @ScriptDir & "/MSDE2000/Setup.exe SECURITYMODE=SQL SAPWD='MyPWD' TARGETDIR='C:\Metronik\MSDE\DB' DATADIR='C:\Metronik\MSDE\Data' DISABLENETWORKPROTOCOLS=0", "", @SW_HIDE) ;Write MSDEInstalled=1 into registry RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\MSDEInstalled", "IsInstalled", "REG_SZ", "1") ;Run SQL script to create DB RunWait(@COMSPEC & " /c " & @ScriptDir & "/DBScript/SetupDB.bat", "", @SW_HIDE) EndIf Else ;If MSDE is installed and user picked CLIENT installation (ClientInstalled=1) -> Remove MSDE If ($clientInstalled = 1) Then ;Uninstall MSDE 2000 RunWait(@COMSPEC & " /c " & @SystemDir & "/msiexec /qn /x{E09B48B5-E141-427A-AB0C-D3605127224A}", "", @SW_HIDE) ;Delete registry key "MSDEInstalled" RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\MSDEInstalled") ;Delete MSDE 2000 directory DirRemove("C:\Metronik", 1) EndIf EndIf Link to comment Share on other sites More sharing options...
MHz Posted July 21, 2006 Share Posted July 21, 2006 (edited) Welcome, The registry reads would return string values, so I would recommend to compare them against string values also. Add quotes around the "1". What I cannot understand is if Urnik.exe installs the programs and adds registry keys is how you get the change of registry when you only read them from the start of script? Surely you would reread the values again? And looks like an Else, then a IF on the following line, should perhaps be ElseIf instead? That would make 1 EndIf obsolete. Edited July 21, 2006 by MHz Link to comment Share on other sites More sharing options...
Aleksandar Hajduković Posted July 21, 2006 Author Share Posted July 21, 2006 Welcome, The registry reads would return string values, so I would recommend to compare them against string values also. Add quotes around the "1". What I cannot understand is if Urnik.exe installs the programs and adds registry keys is how you get the change of registry when you only read them from the start of script? Surely you would reread the values again? And looks like an Else, then a IF on the following line, should perhaps be ElseIf instead? That would make 1 EndIf obsolete. Thanks for reply. Yes, reading a registry values again is necesary :-) A logical mistake for a red card :-) Also changed 1 -> "1" when comparing... Didn't understand that problem about If, Then, Else... It seems ok to me - I have one simple If and then one If Then Else combination with one nested simple If Then inside the each logical part... But as before, scripts stops after new installation and I don't know if script read again my registry and what stoped it... I will try to put MsgBox after each command... New code is: expandcollapse popupAutoItSetOption("RunErrorsFatal", 0) ;Read value from registry key to check if SERVER is allready installed (ServerInstalled="1") $serverInstalled = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\SetupChoice", "ServerInstalled") ;Read value from registry key to check if CLIENT is allready installed (ClientInstalled="1") $clientInstalled = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\SetupChoice", "ClientInstalled") ;Read value from registry key to check if MSDE 2000 is installed (MSDEInstalled="1") $msdeInstalled = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\MSDEInstalled", "IsInstalled") MsgBox(4096, "Debug", "serverInstalled="&$serverInstalled&", clientInstalled="&$clientInstalled&", msdeInstalled="&$msdeInstalled); ;First -> uninstall Urnik application with GUID {A2925D4F-0905-40DB-AB8D-CB4AA79572B3} if it is allready installed If ($serverInstalled = "1" OR $clientInstalled = "1") Then RunWait(@COMSPEC & " /c " & @SystemDir & "/msiexec /qn /x{A2925D4F-0905-40DB-AB8D-CB4AA79572B3}", "", @SW_HIDE) ;Delete possible remained registry keys to be sure that all is deleted RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\Metronik.Timetable") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\SetupChoice") EndIf ;Second -> install again Urnik application from the beginning (user can choose to install SERVER or CLIENT) ;After installation it will have value "ServerInstalled=1" if he picked SERVER or "ClientInstalled=1" if he picked CLIENT RunWait(@COMSPEC & " /c " & @ScriptDir & "/Urnik/Urnik.exe", "", @SW_HIDE) ;Read again value from registry key to check if SERVER is allready installed (ServerInstalled="1") $serverInstalled = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\SetupChoice", "ServerInstalled") ;Read again value from registry key to check if CLIENT is allready installed (ClientInstalled="1") $clientInstalled = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\SetupChoice", "ClientInstalled") ;If MSDE is not installed -> install it only if user picked to install SERVER installation If ($msdeInstalled <> "1") Then ;If SERVER is installed -> only then install MSDE 2000 and create DB If ($serverInstalled = "1") Then ;Install MSDE 2000 RunWait(@COMSPEC & " /c " & @ScriptDir & "/MSDE2000/Setup.exe SECURITYMODE=SQL SAPWD='MyPWD' TARGETDIR='C:\Metronik\MSDE\DB' DATADIR='C:\Metronik\MSDE\Data' DISABLENETWORKPROTOCOLS=0", "", @SW_HIDE) ;Write MSDEInstalled="1" into registry RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\MSDEInstalled", "IsInstalled", "REG_SZ", "1") ;Run SQL script to create DB RunWait(@COMSPEC & " /c " & @ScriptDir & "/DBScript/SetupDB.bat", "", @SW_HIDE) EndIf Else ;If MSDE is installed and user picked CLIENT installation (ClientInstalled="1") -> Remove MSDE If ($clientInstalled = "1") Then ;Uninstall MSDE 2000 RunWait(@COMSPEC & " /c " & @SystemDir & "/msiexec /qn /x{E09B48B5-E141-427A-AB0C-D3605127224A}", "", @SW_HIDE) ;Delete registry key "MSDEInstalled" RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Metronik\MSDEInstalled") ;Delete MSDE 2000 directory DirRemove("C:\Metronik", 1) EndIf EndIf Link to comment Share on other sites More sharing options...
Aleksandar Hajduković Posted July 21, 2006 Author Share Posted July 21, 2006 It seems that is problem in uninstallation of Urnik.exe application. I put a flag /qn for silent uninstallation but it seems that application didn't exist for given GUID. And it didn't uninstall this application so when I come back to install fresh application it offers me to remove the application allready installed so I remove it and then nothing happen (what is expected). How I can find GUID of this installed application - to find the right one? This GUID I copied from InstallShield General information about this application Link to comment Share on other sites More sharing options...
Aleksandar Hajduković Posted July 21, 2006 Author Share Posted July 21, 2006 It seems that is problem in uninstallation of Urnik.exe application.I put a flag /qn for silent uninstallation but it seems that application didn't exist for given GUID. And it didn't uninstall this application so when I come back to install fresh application it offers me to remove the application allready installed so I remove it and then nothing happen (what is expected).How I can find GUID of this installed application - to find the right one?This GUID I copied from InstallShield General information about this applicationProblem solved :-)Removed this row for uninstalling Urnik and instead of that I put it to install it again - which is uninstall really and then I install it again. Not the most elegant solution but I will polish it somehow.Thanks! Link to comment Share on other sites More sharing options...
MHz Posted July 21, 2006 Share Posted July 21, 2006 This is the changes I saw if you are still interested. I saw that you were using single quotes on a commandline which ComSpec would not like. expandcollapse popupAutoItSetOption("RunErrorsFatal", 0) ; Declare variables Global $clientInstalled, $msdeInstalled, $serverInstalled _ReadRegistry() MsgBox(4096, "Debug", "serverInstalled="&$serverInstalled&", clientInstalled="&$clientInstalled&", msdeInstalled="&$msdeInstalled); ;First -> uninstall Urnik application with GUID {A2925D4F-0905-40DB-AB8D-CB4AA79572B3} if it is allready installed If ($serverInstalled = "1" OR $clientInstalled = "1") Then RunWait(@COMSPEC & " /c " & @SystemDir & "/msiexec /qn /x{A2925D4F-0905-40DB-AB8D-CB4AA79572B3}", "", @SW_HIDE) ;Delete possible remained registry keys to be sure that all is deleted RegDelete("HKLM\SOFTWARE\Metronik\Metronik.Timetable") RegDelete("HKLM\SOFTWARE\Metronik\SetupChoice") EndIf ;Second -> install again Urnik application from the beginning (user can choose to install SERVER or CLIENT) ;After installation it will have value "ServerInstalled=1" if he picked SERVER or "ClientInstalled=1" if he picked CLIENT RunWait(@COMSPEC & " /c " & @ScriptDir & "/Urnik/Urnik.exe", "", @SW_HIDE) _ReadRegistry() ;If MSDE is not installed -> install it only if user picked to install SERVER installation If ($msdeInstalled <> "1") Then ;If SERVER is installed -> only then install MSDE 2000 and create DB If ($serverInstalled = "1") Then ;Install MSDE 2000 RunWait(@COMSPEC & " /c " & @ScriptDir & '/MSDE2000/Setup.exe SECURITYMODE=SQL SAPWD="MyPWD" TARGETDIR="C:\Metronik\MSDE\DB" DATADIR="C:\Metronik\MSDE\Data" DISABLENETWORKPROTOCOLS=0', "", @SW_HIDE) ;Write MSDEInstalled="1" into registry RegWrite("HKLM\SOFTWARE\Metronik\MSDEInstalled", "IsInstalled", "REG_SZ", "1") ;Run SQL script to create DB RunWait(@COMSPEC & " /c " & @ScriptDir & "/DBScript/SetupDB.bat", "", @SW_HIDE) EndIf ;If MSDE is installed and user picked CLIENT installation (ClientInstalled="1") -> Remove MSDE ElseIf ($clientInstalled = "1") Then ;Uninstall MSDE 2000 RunWait(@COMSPEC & " /c " & @SystemDir & "/msiexec /qn /x{E09B48B5-E141-427A-AB0C-D3605127224A}", "", @SW_HIDE) ;Delete registry key "MSDEInstalled" RegDelete("HKLM\SOFTWARE\Metronik\MSDEInstalled") ;Delete MSDE 2000 directory DirRemove("C:\Metronik", 1) EndIf Func _ReadRegistry() ;Read value from registry key to check if SERVER is allready installed (ServerInstalled="1") $serverInstalled = RegRead("HKLM\SOFTWARE\Metronik\SetupChoice", "ServerInstalled") ;Read value from registry key to check if CLIENT is allready installed (ClientInstalled="1") $clientInstalled = RegRead("HKLM\SOFTWARE\Metronik\SetupChoice", "ClientInstalled") ;Read value from registry key to check if MSDE 2000 is installed (MSDEInstalled="1") $msdeInstalled = RegRead("HKLM\SOFTWARE\Metronik\MSDEInstalled", "IsInstalled") EndFunc Link to comment Share on other sites More sharing options...
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