There is a way to validate the value passed by command line with /DIR= parameter? Something like this:
C:\>MySetup.exe /DIR="An\invalid\path\here"
By validate I mean: if the directory doesn't exist, I would like to use the default value of the constant {app}, considering that the software may already be installed (UserPreviousAppDir=yes).
I tried to validate the value passed by /DIR= with CurPageChanged() in [Code] section.
[Code]
procedure CurPageChanged(CurPageID: Integer);
var
Dir, DirCmd: String;
begin
if (CurPageID = wpSelectDir) then
begin
// default directory
Dir := ExpandConstant('{app}'); // <- Error here
// test /DIR parameter
DirCmd := ExpandConstant('{param:DIR|0}');
if ( DirExists(DirCmd) ) then
Dir := DirCmd;
// set Select Destination Location page
WizardForm.DirEdit.Text := Dir;
end;
end;
The problem I see is that before the Select Destination Location page the constant {app} has not been defined yet and WizardDirValue() has the same value passed by /DIR=. So I can check that the directory do or not exists, but I can't find a way to replace it with the default value of {app} if no /DIR= had been used.