Archive: Extract file with another name


Extract file with another name
Hi,

I have a multi-language installer with three language files in it:

Language file 1 = Res_EN.DLL
Language file 2 = Res_FR.DLL
Language file 3 = Res_DE.DLL

What I want to do is renaming the file to RES.DLL based on the language choosen by the user.

I tried different things with the "File" instruction and the "/oname" parameter but I'm unable to get this working.

Any help is welcome

Romain


I'm assuming you have an InstallOptions page there, so the user gets to select between 3 different RadioButtons, in this case Field 1-3.
It will read from Field 1 and if it is set to 1 (state), it will install the English dll (jumpto InstallEN.)
If Field 1 is set to 0 then it will read from Field 2.
If Field 2 is set to 1, it will install the French dll and so on.




InitPluginsDir
ReadINIStr $0 "$PLUGINSDIR\language.ini" "Field 1" "State"
StrCmp $0 1 InstallEN

ReadINIStr $0 "$PLUGINSDIR\language.ini" "Field 2" "State"
StrCmp $0 1 InstallFR

ReadINIStr $0 "$PLUGINSDIR\language.ini" "Field 3" "State"
StrCmp $0 1 InstallDE


InstallEN:
File /oname=$INSTDIR\Res.dll "C:\path\to\Res_EN.DLL"
goto done

InstallFR:
File /oname=$INSTDIR\Res.dll "C:\path\to\Res_FR.DLL"
goto done

InstallDE:
File /oname=$INSTDIR\Res.dll "C:\path\to\Res_DE.DLL"

done:


Hope that helps.
Edit: where language.ini is the InstallOptions INI file.

The code can go in the InstFiles sections, or you could have it in the pre function of the next page.

If your using modern ui and you have the InstallOptions page before the Welcome page, then you can add this to your script:


!define MUI_CUSTOMFUNCTION_WELCOME_SHOW "languages"


Where "languages" is the funtion that all that stuff above will go in.
It will call the function just before the welcome page shows.

If you aren't using modern ui, then use Page Welcome "languages"

-Stuart

Hope that helps.
Yes, it works !

Many thanks