1

我的 Inno Script 安装程序在 C: 驱动器中创建了一个空文件夹,但仅在一台机器上。我测试过脚本的所有其他机器都没有这个问题。我在两台 Windows 7 计算机、一台 XP 计算机和一台 Windows XP 虚拟计算机上进行了测试。对于所有这些计算机,安装程序不会创建这个空文件夹。

但是,在我同事的 Windows XP 计算机上,安装程序的行为正常,只是它还在 C 驱动器上创建了一个空目录。卸载不会删除该文件夹。

我查看了我的脚本并寻找可能创建额外文件夹的内容,但我什么也看不到。这特别难以解决,因为我似乎无法复制这个问题。

这里有人知道为什么会发生这种情况吗?

#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;
4

1 回答 1

0

对于那些可能遇到类似问题的人:Inno setup 突然创建了我不想拥有的额外空文件夹。最后我明白了原因:我试图在 [Files] 部分中创建一个空文件夹。这不是一个好主意......所以你只需用 [Dirs] 部分创建你的空文件夹来做这件事。

不要这样做:

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

这个更好:

[Dirs]
Name: "{userdocs}\My_App_Name\My_Empty_Folder"
于 2014-12-31T11:51:56.473 回答