trust11
29th June 2007 15:22 UTC
Help please
Hi all
I have a lot of things that i dont know how to do. Can you help me please?
1.- I have to install SQL Server Express 2005 SP2 (ive done it) but only if there isnt any version of SQL Server installed.
This is how i install SQL Server:
File "SQLEXPR.EXE"
ExecWait '$INSTDIR\SQLEXPR_ESN.EXE /qb ADDLOCAL=SQL_Engine INSTANCENAME=MSSQLSERVER SECURITYMODE=SQL SAPWD=onix SQLCOLLATION="Modern_Spanish_CI_AS" SQLAUTOSTART=1 DISABLENETWORKPROTOCOLS=0'
2.- When the user uninstalls the program i should uninstall SQL Server and the framework. How can i do it ?
This is the code of the uninstall section:
Section "Uninstall"
RMDir "$INSTDIR"
Delete "$DESKTOP\PymesON.lnk"
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\${APPNAME}.lnk"
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
startMenuDeleteLoop:
ClearErrors
RMDir $MUI_TEMP
GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
IfErrors startMenuDeleteLoopDone
StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
startMenuDeleteLoopDone:
DeleteRegKey HKCR ".mcr"
DeleteRegKey HKCR "mcrfile"
DeleteRegKey HKCR "mcrfile"
DeleteRegKey HKCU "SOFTWARE\microsoft\Internet Explorer\Extensions\{8491AFCD-14CE-449B-A4F8-0AA5AF2B66DB}"
DeleteRegKey /ifempty HKCU "Software\${APPNAME}"
SectionEnd
Can you help me please?? Please...
Afrow UK
29th June 2007 15:54 UTC
Can you not check the registry for an existing version?
Also, you should have quotes around your path for ExecWait.
ExecWait '"$INSTDIR\SQLEXPR_ESN.EXE" /qb ... '
If you don't and the path contains spaces then ExecWait will fail.
Stu
trust11
29th June 2007 16:13 UTC
How can i check the registry for an existing version?
Im new in all this .. i dont know how and where can i do it....
Afrow UK
29th June 2007 16:22 UTC
See ReadRegStr in the manual. VersionCompare will also be necessary if you want to check for a certain version. Use RegEdit to find a suitable registry key to use for your install, or use Google.
Stu
trust11
2nd July 2007 08:36 UTC
Thanks Afrow UK.
I have done it with this code:
ReadRegStr $R0 HKLM \"SOFTWARE\Microsoft\MSSQLServer\Setup" SQLPath ;ProductCode
${If} $R0 == ""
File "SQLEXPR_ESN.EXE" ExecWait '$INSTDIR\SQLEXPR_ESN.EXE /qb ADDLOCAL=SQL_Engine INSTANCENAME=MSSQLSERVER SECURITYMODE=SQL SAPWD=onix SQLCOLLATION="Modern_Spanish_CI_AS" SQLAUTOSTART=1 DISABLENETWORKPROTOCOLS=0'
${Else}
;MessageBox MB_ICONEXCLAMATION|MB_OK "SQL Server/MSDE already installed!$\nSQL Path:$R0$\nSetup is terminating the installation process."
;Quit
${EndIf}
About the other question.. How can i uninstall SQL Server? Can you help me please?
trust11
2nd July 2007 10:36 UTC
And i only should uninstall it if i have installed it...
Ufff... Can someone help me please?
CancerFace
2nd July 2007 10:53 UTC
From what I can see, SQL is an MSI package. To uninstall it you can look at HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\[some key for SQL] for its uninstall entry and call from your script the value given in the UninstallString found in the registry.
As for uninstalling it only if you have installed it, you could add to your installer a registry value (for example under HKLM\Software\YourCompanyName or something similar), then look for that value from your uninstaller and if it is there then call the uninstall string for the MSI pack ...
Hope this helps
CF
trust11
2nd July 2007 11:31 UTC
Hi CancerFace:
Im trying to dot this.
This is the code when i add a registry value on install:
WriteRegStr HKLM "SOFTWARE\MyAPP\MyAPP" "1" "1"
On uninstall im trying with this:
ReadRegStr $R0 HKLM \
"SOFTWARE\MyAPP\MyAPP" 1
${If} $R0 <> ""
ReadRegStr $R1 HKLM \ "SOFTWARE\Microsoft\MSSQLServer\UninstallPath" SQLPath ;ProductCode
${If} $R1 <> ""
ExecWait '$R1'
${EndIf}
${EndIf}
But this isnt working.
What im doing bad??
CancerFace
2nd July 2007 15:20 UTC
This is what I had in mind:
Installer:
WriteRegStr HKLM "SOFTWARE\MyAPP" "Installed" "1"
Uninstaller:
ReadRegStr $R0 HKLM "SOFTWARE\MyAPP" "Installed"
${If} $R0 == 1
# add here the actual uninstall string for the MSI pack
${EndIf}
The uninstall string you will find, as I already pointed out, under
HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\[some key for SQL]
For example, the Intel Alert Agent on the Dell machine I use at work has its uninstaller found in
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3C50A915-DD33-4802-B83B-9EA997D3337B}
and specifically the uninstall string is at the key called
UninstallString with a value of
MsiExec.exe /I{3C50A915-DD33-4802-B83B-9EA997D3337B}
So if I wanted to start this uninstaller for the Intel Alert Agent I would call (within my uninstaller):
ReadRegStr $R0 HKLM "SOFTWARE\MyAPP" "Installed"
${If} $R0 == 1
ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3C50A915-DD33-4802-B83B-9EA997D3337B}" "UninstallString"
${If} $R1 != ""
ExecWait '$R1'
${EndIf}
${EndIf}
CF
demiller9
2nd July 2007 20:09 UTC
Just to head off another possible problem, some install packages put the /I parameter into the uninstall string, but actually need /X to do the uninstall (this is from Crystal Reports):
!define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
ReadRegStr $R0 HKLM "${UNINSTALL_KEY}\{2F8728F9-F239-46A0-9DE2-8AD7302E4B33}" "UninstallString"
; modify the command (/I becomes /x)
${un.WordReplace} "$R0" "/I{" "/x{" "+" "$R0"
ExecWait "$R0 /qn /norestart"
Don
Afrow UK
3rd July 2007 09:35 UTC
I'll say it again for everyone. You have to use quotes around the executable path, otherwise it will not execute if you have a space in the path.
E.g.
$R0 = "C:\Program Files\MyApp\file.exe"
ExecWait "$R0 /args"
This will become:
ExecWait "C:\Program Files\MyApp\file.exe /args"
As you can seem C:\Program is not the executable!
Stu