Old 1st October 2003, 16:36   #1
SGI
Junior Member
 
Join Date: Jul 2003
Location: USA
Posts: 34
autouninstall

I have my autouninstall...but when Im running the autouninstaller there is the install window behind him ready.
I want to start the new installation only if is unistalled the old program and stop the installation (new program), if they dont accept the upgrade/cancell.
Thank you

ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME}" "uninstallstring"
StrCmp $1 "" cont
StrCmp $0 "" done
cont:
HideWindow
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"This wizard will autouninstall the ${PROD_NAME}. $\n$\nIt is strongly recommended that you uninstall manually any previous versions of \
${PROD_NAME} 2.5.${VER_MINOR}$\n$\nClick `OK` to install or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort

uninst:
ClearErrors
ExecWait '"$INSTDIR\uninstall.exe" /S_?=$INSTDIR'

done:
BringToFront
SGI is offline   Reply With Quote
Old 1st October 2003, 16:45   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
If you want to close the installer that runs the uninstaller, use
Exec '"$INSTDIR\uninstall.exe" /S_?=$INSTDIR'
Quit

You could pass a command-line parameter to the uninstaller to be read in the uninstaller to re-run the installer when the uninstall is complete.

E.g.
In installer .onInit
Exec '"$INSTDIR\uninstall.exe" /S_?=$INSTDIR yes'
Quit

In uninstaller
Section Uninstall
...
Call GetParameters
Pop $R0
StrCmp $R0 "/S_?=$INSTDIR yes" 0 noQuit
Exec installer.exe
Quit
noQuit:
SectionEnd

-Stu
Afrow UK is offline   Reply With Quote
Old 1st October 2003, 17:31   #3
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
You'd better send the filename of the installer, because the user might have renamed the file.

See http://nsis.sourceforge.net/archive/...b.php?page=427
Joost Verburg is offline   Reply With Quote
Old 1st October 2003, 17:42   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Ah yes!
Thinking about it now, it's probably easier to write the extra parameters to a temp ini file or to the registry, so that a string function isn't required to get hold of the sent command-line parameters.

E.g.
In installer .onInit
Call GetEXEName
Pop $R0
WriteINIStr "$TEMP\myinstaller.tmp" "Installer" "InstallerEXE" "$EXEDIR\$R0"
Exec '"$INSTDIR\uninstall.exe" /S_?=$INSTDIR'
Quit

In uninstaller
Section Uninstall
...
IfFileExists "$TEMP\myinstaller.tmp" 0 noQuit
ReadINIStr $R0 "$TEMP\myinstaller.tmp" "Installer" "InstallerEXE"
Exec "$R0"
Delete "$TEMP\myinstaller.tmp"
Quit
noQuit:
SectionEnd
Afrow UK is offline   Reply With Quote
Old 1st October 2003, 17:45   #5
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
I think using the command line is a good solution.
Joost Verburg is offline   Reply With Quote
Old 1st October 2003, 19:07   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
A simpler solution would be reading the uninstaller's return value. As stated in C.2 Error Levels, the uninstaller will return 1 if the process failed. Read it using the second parameter of ExecWait. For example:

ExecWait '"$INSTDIR\uninstall.exe" _?=$INSTDIR' $0
StrCmp $0 0 goodToGo
Abort
goodToGo:

BTW, you have an error in your call to the uninstaller. It seems as you've tried to make the uninstaller silent but missed a space after the /S parameter. I have removed it in my example because you've talked about the user clicking the cancel button, which is impossible if the uninstaller is silent.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 1st October 2003, 19:16   #7
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
But in that case the installer keeps running. The command line is used to send the installer filename.
Joost Verburg is offline   Reply With Quote
Old 1st October 2003, 19:19   #8
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
The installer should wait for the uninstaller if using _?=$INSTDIR on the command line.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 1st October 2003, 19:25   #9
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
Yes, but it keeps running. It's nicer to close it until the uninstallation has completed.
Joost Verburg is offline   Reply With Quote
Old 1st October 2003, 19:29   #10
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
HideWindow takes care of that, it shouldn't even show on the taskbar. And if this is used in .onInit, there is nothing to worry about anyway.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 2nd October 2003, 17:55   #11
SGI
Junior Member
 
Join Date: Jul 2003
Location: USA
Posts: 34
I never had a moment to try your script "help".
But thank you ....I'll let you know when I have free time.
SGI is offline   Reply With Quote
Old 9th October 2003, 04:06   #12
SGI
Junior Member
 
Join Date: Jul 2003
Location: USA
Posts: 34
I tried your script and I have in thefollowing problem:
this is my script MUI_STARTMENUPAGE_DEFAULTFOLDER "${PROD_NAME}"
and I have the name of the "OutFile" myinstaller1122.ex be carefull no all name of the outfile ....missing letter e.
So far..this is working great if the users dont change the name of the installer:
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME}" "uninstallstring"
StrCmp $1 "" cont
StrCmp $0 "" done
cont:
HideWindow
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"This wizard will autouninstall the ${PROD_NAME}. $\n$\nIt is strongly recommended that you uninstall manually any previous versions of \
${PROD_NAME} 2.5.${VER_MINOR}$\n$\nClick `OK` to install or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort
uninst:
ClearErrors
ExecWait '"$INSTDIR\uninstall.exe" _?=$INSTDIR' $0
StrCmp $0 0 goodToGo
Abort
goodToGo:
done:
BringToFront
I have two choices :
-First: the users are unable to change the name.
-Second: find to do exactly what we want (best choice).
SGI is offline   Reply With Quote
Old 9th October 2003, 11:02   #13
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
What does the name of the installer has to do with this? You don't execute it. What exactly do you mean by "find to do exactly what we want (best choice)."?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 9th October 2003, 13:12   #14
SGI
Junior Member
 
Join Date: Jul 2003
Location: USA
Posts: 34
I used Afrow Uk script and I have the name of the installer myinstaller1122.ex("OutFile") and there I need my ${PROD_NAME}
MUI_STARTMENUPAGE_DEFAULTFOLDER "${PROD_NAME}"

And what I mean "about" find to do exactly what we want (best choice). is to allow the users to change the name of the installer and autouninstall it.
But I found another problem: if the users changed the name of the previous version the new installer (with autouninstall) doesnt work.
Probably the best way is not to allow to change the name.
Attached Files
File Type: txt afrow uk example.txt (724 Bytes, 247 views)
SGI is offline   Reply With Quote
Old 9th October 2003, 13:18   #15
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
You don't need Afrow's functions anymore. The code in your last post should be enough.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 9th October 2003, 14:20   #16
SGI
Junior Member
 
Join Date: Jul 2003
Location: USA
Posts: 34
Thank you Kichik im thinking to use your code...is great.
And going to "not allow to change the name"
SGI is offline   Reply With Quote
Old 9th October 2003, 16:45   #17
SGI
Junior Member
 
Join Date: Jul 2003
Location: USA
Posts: 34
Btw I forgot to tell you ...I wrote that error on the Afrow UK on my installer to try to fix or see if is only a my problem.
I resolved my problem , with your script , but the forum is for all people no just for my script.
Thank you again for your patience.
SGI is offline   Reply With Quote
Old 12th October 2003, 06:00   #18
SGI
Junior Member
 
Join Date: Jul 2003
Location: USA
Posts: 34
Sorry Im back again....the autouninstaller was always triggered
even if no prior version of the program was installed.
SGI is offline   Reply With Quote
Old 12th October 2003, 11:00   #19
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Please attach the entire script.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 12th October 2003, 13:46   #20
SGI
Junior Member
 
Join Date: Jul 2003
Location: USA
Posts: 34
Thank you shoot the file....
SGI is offline   Reply With Quote
Old 12th October 2003, 13:47   #21
SGI
Junior Member
 
Join Date: Jul 2003
Location: USA
Posts: 34
Sorry and thank you again...in the other post I attached the ini file.

Link to INi file
Attached Files
File Type: nsi bzfsgui26final.nsi (7.5 KB, 272 views)
SGI is offline   Reply With Quote
Old 12th October 2003, 13:55   #22
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
There is no place in the script where you actually write to HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME}" "UninstallString". If you don't write anything there, the script won't be able to read anything from there. You should also write this key so your uninstaller would be listed in the Add/Remove control panel. See Appendix C - "Add uninstall information to Add/Remove Programs" for more information.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump