1

My Inno Script installer makes an empty folder in the C: drive but only on one machine. Every other machine I've tested the script on works without this problem. I've tested on two Windows 7 computers, an XP computer and a Windows XP virtual computer. For all of these computers the installer doesn't create this empty folder.

However, on my colleague's Windows XP computer the installer behaves as it should except that it also creates an empty directory on the C Drive. Uninstalling does not remove the folder.

I've had a look through my script and looked for things that could possibly be creating the extra folder, but I can't see anything. It's especially hard to solve because I can't seem to replicate the problem.

Does anyone here have an idea of why this could be happening?

#define MyAppName "Program1"
#define MyAppVersion "1.0"
#define MyAppExeName "program1.exe"

[Setup]
AppName=Test
AppVersion=1.0
AppPublisher=Me
AppSupportURL=www.google.com
AppUpdatesURL= www.google.com

DefaultDirName={code:getDirectory}
UsePreviousAppDir=no
DisableDirPage=yes
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputBaseFilename={#MyAppName} {#MyAppVersion} Setup
Compression=lzma
SolidCompression=yes
OutputDir=output
UninstallFilesDir={code:getDirectory}


[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"

[Files]
Source: "test.iss"; DestDir: "{code:getDirectory}"; Flags: ignoreversion;

[Code]

var
  InstallTestVersionCheckBox: TNewCheckBox;
  Directory : string;


// ------------------------------
// INSTALL
// ------------------------------ 
procedure InitializeWizard;
var  
  MainPage: TWizardPage;


begin

  MainPage := CreateCustomPage(wpWelcome, 'text', 'text');

  // make the checkbox
  InstallTestVersionCheckBox := TNewCheckBox.Create(MainPage);
  InstallTestVersionCheckBox.Parent := MainPage.Surface;
  InstallTestVersionCheckBox.Caption := 'Test Version';

end;

function InstallTestVersion: Boolean;
begin
  Result := InstallTestVersionCheckBox.Checked;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if InstallTestVersion() then
    begin
      // Set the test version directory
      Directory := ExpandConstant('{pf32}\Testversion');
    end
  else
    begin
      // Set the production version directory
      Directory := ExpandConstant('{pf32}\Normal');
    end;
end;

// Returns the correct directory
function getDirectory(Param: String): String;
begin
  Result := Directory;
end;
  • As far as I know, the only folder that Inno Setup creates automatically is its own temporary folder, but it's not empty while the wizard is running and should be deleted after it's done. – TLama Sep 27 '13 at 11:34
  • Check if TEMP folder is proprerly set and accessible on this very machine. It may happen that TEMP is not set or is no acccessible and Installer tries to create own temporary folder on root C:\. E.g. M$ .NET and VC++ can create own temp folder on ROOT C or other (normally on the disk with the largest free space) if WorkingDir is not set. – RobeN Sep 27 '13 at 11:34
  • I've discovered that what it thinks it's doing is creating a "Dest" folder. I'll read the docs about this. – user2823160 Sep 27 '13 at 12:43
  • Does anyone know if there's a way to change the destination folder so I can control where it makes the folder, or at least control its name? – user2823160 Sep 27 '13 at 12:50
  • If you mean the default directory shown in the *"Select Destination Location"* wizard page, then it's the `DefaultDirName` directive from the `[Setup]` section. – TLama Sep 27 '13 at 13:15
  • I've found the problem, but I'm not sure what I can do to fix it. The problem is that I've been using a function to set the DefaultDirName. For some reason, this causes the folder on C Drive to be created. If I don't use a function to set it, then the folder isn't created. Trouble is that the installer must choose during the install where the program will be installed based off a checkbox. So even if I set the DefaultDirName manually, then if it chooses a different path to install on I have an empty folder because the default isn't used. – user2823160 Sep 30 '13 at 07:06
  • Wait, you are using a function in `[Code]` section to set the `DefaultDirName` directive ? Please be precise. These are very specific terms that must be used. Better show a minimalistic script on which we can reproduce the problem you have. Anyway, if you want to notify someone with a comment, add `@` before his/her name (like e.g. @TLama would notify me). We don't have to do it, since you're the question owner, so you are notified about every comment we leave here. So please [`edit your question`](http://stackoverflow.com/posts/19049636/edit) and add a minimalistic script to reproduce. – TLama Sep 30 '13 at 07:56
  • @TLama That's a stripped down version of the code. Yes, I am using a function in [Code] to set the DefaultDirName directive. The problem is that the DefaultDirName folder is always created even when I don't need it, because the DefaultDirName folder may not be used. In that scenario, I have a folder I need to delete after the install. Surely there is a better way, or some kind of flag I can set to stop it creating the folder? Thanks for all the help by the way. – user2823160 Sep 30 '13 at 08:32

1 Answers1

0

For those who might run into similar problems: Inno setup suddenly created additional empty folders I didn't want to have. Finally I understood the reason: I tried to create a single empty folder within the [Files] section. That was no good idea... So you just create your empty folder with the [Dirs] section to do it the good way.

DO NOT DO THIS:

[Files]
Source: "M:\My_Empty_Folder"; DestDir: "{userdocs}\My_App_Name"; Flags: ignoreversion

THIS IS BETTER:

[Dirs]
Name: "{userdocs}\My_App_Name\My_Empty_Folder"
David 10K
  • 303
  • 2
  • 14