|
|
|
|
#1 |
|
Junior Member
Join Date: Jul 2008
Posts: 3
|
Restart Section
Hi!
I`ve been looking at some advises here, but they didn`t help me a lot. So maybe somebody else can help me. My installer checks the installation path, and if it is a forbidden path, it stops the installation. What i`ve been trying to do, is when the installer is stopped, it goes back to the DIRECTORY page and asks the user to select another path. I`m using this code: Function RelGotoPage IntCmp $R9 0 0 Move Move StrCmp $R9 "X" 0 Move StrCpy $R9 "120" Move: SendMessage $HWNDPARENT "0x408" "$R9" "" FunctionEnd !macro BadPathsCheck StrCpy $R0 $INSTDIR "" -2 StrCmp $R0 ":\" bad StrCpy $R0 $INSTDIR "" -14 StrCmp $R0 "\Program Files" bad StrCpy $R0 $INSTDIR "" -8 StrCmp $R0 "\Windows" bad StrCpy $R0 $INSTDIR "" -6 StrCmp $R0 "\WinNT" bad StrCpy $R0 $INSTDIR "" -9 StrCmp $R0 "\system32" bad StrCpy $R0 $INSTDIR "" -8 StrCmp $R0 "\Desktop" bad StrCpy $R0 $INSTDIR "" -22 StrCmp $R0 "\Documents and Settings" bad StrCpy $R0 $INSTDIR "" -13 StrCmp $R0 "\My Documents" bad good bad: MessageBox MB_OK|MB_ICONSTOP "Install path invalid! You should chose another install path." StrCpy $R9 -1 ;Goto the next page Call RelGotoPage good: !macroend Section InstallComponents !insert BadPathsCheck ... Some code here that installs files... SectionEnd The point is, that ( maybe i`m mistaken, but i keep getting errors ) Section continues to execute installation of the files, even though it shows the Directory page. Is there a way to make the Section restart, or pause? |
|
|
|
|
|
#2 |
|
Major Dude
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
|
It would be a better way to check the path before the user is allowed to leave the DIRECTORY page! You can use the CallbackFunction of the directory page to do this. Just assign a "[leave_function]" function to your directory page. In that function check whether $INSTDIR is valid or not. If it's not valid, then simply call Abort ...
My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc My source of inspiration: http://youtu.be/lCwY4_0W1YI |
|
|
|
|
|
#3 |
|
Major Dude
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
|
Here is an example:
code: My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc My source of inspiration: http://youtu.be/lCwY4_0W1YI |
|
|
|
|
|
#4 |
|
NSIS MUI Dev
Join Date: Nov 2001
Posts: 3,717
|
There is no need for a custom leave function, use the standard .onVerifyInstDir callback function.
|
|
|
|
|
|
#5 |
|
Major Dude
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
|
You are right. But then you check the directory more often, not only when the user tries to leave the directory page. Depends on what you want to achieve. Try this and compare the result with my first example above:
code: In case you want to display an error message to the user, when an invalid directory has been selected, I would go with the custom leave function instead of .onVerifyInstDir function. Otherwise you would bomb the user with too many message boxes... My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc My source of inspiration: http://youtu.be/lCwY4_0W1YI |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jul 2008
Posts: 3
|
Huge thanx, guys. The installation works fine now.
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|