3

I would like to know how to fix this kind of Error:

You must enter a full path with drive letter; for example: C:\APP or a UNC path in the form: \server\share

This appears whenever I try to force the Inno Setup Compiler (5.5.5 u) to put my stuff into, let say H:\ instead of H:\New Folder.

I need the compiler to customize my destination location to H:\.

Here is my sample program;

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={drive:F:}
AppendDefaultDirName=no

[Files]
Source: "File1.txt"; DestDir: "{code:GetExeLocation|{app}\My_Portable_App}"; \
  Flags: ignoreversion 
[Code]
var
  UsagePage: TInputOptionWizardPage;

procedure InitializeWizard;
begin
  { Create the pages }
  UsagePage := CreateInputOptionPage(wpWelcome,
    'Installation Type', 'Select Installation Option',
    'Where would you like to install this program',
    True, False);
  UsagePage.Add('Normal – PC Hard Disk Installation ');
  UsagePage.Add('Portable – USB Drive Installation');

  {Set Default – Normal Install}
  UsagePage.SelectedValueIndex := 0;
end;

var
  bIsPortable : Boolean;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  // If we have clicked the next button on our custom page.
  if (CurPageID = UsagePage.ID) then
  begin
    bIsPortable := not (UsagePage.SelectedValueIndex = 0);
  end;
  result := true; // need to return a value so next key has an impact
end;

function GetExeLocation (Param: String) : String;
begin
  if bIsPortable then
    result := Param
  else
    result := Param;
end;

function InstallType(sRequiredType:String):Boolean;
begin
  if sRequiredType = 'Portable' then
    result := bIsPortable
  else
    result := not bIsPortable;
end;

Explanation:

When I select "Normal – PC Hard Disk Installation", as my choice, all my installation files or folders should go to normal Path that is to C:\My Program, but when I select "Portable – USB Drive Installation" as my Entry, I would like to put all my installation files or folders directly into the USB Pen drive Root, that is in here H:\, where "H" is my USB Pen Drive letter which I have selected to put my stuff in. But my Program does not allow me to do so, instead it adds a New Folder by default to put my installation files or folders over there, that is to H:\New Folder which I do not need that at all!. And when I force to do what I want, it ends giving me an Error!

Please I need Your Help to fix this, and if this inno-setup can not do what I want, please point me another one, and I will be Thankful for that!

EDIT:

Let focus on the second choice that is "('portable – usb drive installation')" because that is my real target.

From the Source: I made some changes so that to make it more clear.

I added my destination Directory, that is {code:GetExeLocation|{app}\My_Portable_App}. So what I want here is that, all my installation files or folders to be installed inside this directory, I mean My_Portable_App. And the path to my USB pen drive should be H:\My_Portable_App. So when this goes fine, I want to see only This Folder My_Portable_App in my USB pen drive that will contain all my stuffs in there!!!

Thanks in advance!

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Dr.HansB-RM
  • 45
  • 1
  • 6
  • So, that `H:\ ` is a mapped drive ? And what do you mean by that you are getting that error if you select `H:\..(here!)....` instead of `H:\New Folder` ? Could you be more specific (possibly with a specific example), please ? – TLama Nov 02 '14 at 11:55
  • Thanks TLama for your quick response! I have posted an Example so that you can pass through and if stil not some how clear to be answered, let me know please! – Dr.HansB-RM Nov 03 '14 at 07:42
  • I will be waiting for your reply, TLama!!! – Dr.HansB-RM Nov 03 '14 at 17:49

3 Answers3

1

If you want to install directly into h:\ then you should explicitly enter that into the location box. If you also want to stop the My Program being appended after using the browse dialog then you need to ensure that AppendDefaultDirName is set to no.

Also note that for file2, the DestDir will end up being set to {app}/{app} if bIsPortable is true which will most likely expand to an invalid path.

Your best option is to use a {code:...} function to create a single "default" path based on bIsPortable and then everything can just install into {app} from there.

Deanna
  • 23,876
  • 7
  • 71
  • 156
  • Thanks Deanna for your nice reply! – Dr.HansB-RM Nov 03 '14 at 17:33
  • I passed through your advice and I made some changes, also I tried to put my installation path manually but when I press Next Button,still an error occur. Please look on my small changes that I have made and you may find a way to help me! – Dr.HansB-RM Nov 03 '14 at 17:44
1

I struggled with the validation too, where root was not valid in the TInputDirWizardPage. As it turns out there is a simple Inno Setup option that changes this behavior:

AllowRootDirectory=yes

will allow the user to specify a drive root without error. also see,

AllowUNCPath=yes/no

and

AllowNetworkDrive=yes/no

in the Inno help file for other validation modifiers that apply to the Select Destination Location Page.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Thomas F
  • 11
  • 1
0

This setup file must be located on disc c:. That's all.