在Inno Setup命令行上使用DIR开关

时间:2019-05-31 20:47:18

标签: inno-setup

脚本

我创建了这个简单的脚本:

[ISPP]
; SignTool parameters
#define SignedDesc "$qxxx$q"
#define SignedPfx "$qxxx$q"
#define SignedTimeStamp "$qhttp://timestamp.verisign.com/scripts/timestamp.dll$q"
#define SignedPw "$qxxx$q"

#define AppURL "http://www.publictalksoftware.co.uk"
#define AppPublisher "Andrew Truckle"

[Setup]
DisableReadyPage=True
DisableReadyMemo=True
DisableFinishedPage=True
UsePreviousSetupType=False
UsePreviousTasks=False
UsePreviousLanguage=False
FlatComponentsList=False
AlwaysShowComponentsList=False
ShowComponentSizes=False
AppName=Public Talks Help Documentation
AppVersion=19.0.0
CreateAppDir=False
Uninstallable=no
OutputBaseFilename=PublicTalksHelpDocumentationSetup
SourceDir=D:\My Programs\2019\CommunityTalks\HelpNDoc\CHM
SignTool=SignTool /d {#SignedDesc} /du $q{#AppURL}$q /f {#SignedPfx} /p {#SignedPw} /t {#SignedTimeStamp} /v $f
AppId={{xxx}

[Files]
Source: "CommunityTalks.chm"; DestDir: "{app}"; Flags: ignoreversion

如您所见,这非常简单。它旨在由我的主应用程序执行。


测试

我决定通过对批处理文件进行测试来模仿我的应用程序将要执行的操作。这是批处理文件命令:

PublicTalksHelpDocumentationSetup /SP- /VERYSILENT /DIR="C:\Program Files (x86)\Public Talks" /LOG=".\TestInstallLog.txt"

结果

从表面上看,我认为它可行。除了被要求运行该应用程序的权限外,我在屏幕上什么都没有看到。但是我在指定的 DIR 文件夹中找不到文件。

所以我又看了一下日志:

2019-05-31 21:32:02.971   Log opened. (Time zone: UTC+01:00)
2019-05-31 21:32:02.971   Setup version: Inno Setup version 6.0.2 (u)
2019-05-31 21:32:02.971   Original Setup EXE: D:\My Programs\2019\CommunityTalks\HelpNDoc\CHM\Output\PublicTalksHelpDocumentationSetup.exe
2019-05-31 21:32:02.971   Setup command line: /SL5="$15002A,25665310,721408,D:\My Programs\2019\CommunityTalks\HelpNDoc\CHM\Output\PublicTalksHelpDocumentationSetup.exe" /SPAWNWND=$30900 /NOTIFYWND=$30914 /SP- /VERYSILENT /DIR="C:\Program Files (x86)\Public Talks" /LOG=".\TestInstallLog.txt"
2019-05-31 21:32:02.971   Windows version: 10.0.17763  (NT platform: Yes)
2019-05-31 21:32:02.972   64-bit Windows: Yes
2019-05-31 21:32:02.972   Processor architecture: x64
2019-05-31 21:32:02.972   User privileges: Administrative
2019-05-31 21:32:02.973   Administrative install mode: Yes
2019-05-31 21:32:02.973   Install mode root key: HKEY_LOCAL_MACHINE
2019-05-31 21:32:02.973   64-bit install mode: No
2019-05-31 21:32:02.979   Created temporary directory: C:\Users\ajtru\AppData\Local\Temp\is-1NT54.tmp
2019-05-31 21:32:03.227   Calling RestartManager's RmGetList.
2019-05-31 21:32:03.350   RmGetList finished successfully.
2019-05-31 21:32:03.350   RestartManager found no applications using one of our files.
2019-05-31 21:32:03.356   Starting the installation process.
2019-05-31 21:32:03.360   -- File entry --
2019-05-31 21:32:03.360   Dest filename: C:\WINDOWS\CommunityTalks.chm
2019-05-31 21:32:03.364   Time stamp of our file: 2019-05-30 18:35:24.000
2019-05-31 21:32:03.364   Installing the file.
2019-05-31 21:32:03.539   Successfully installed the file.
2019-05-31 21:32:03.539   Installation process succeeded.
2019-05-31 21:32:03.539   Need to restart Windows? No
2019-05-31 21:32:03.541   Deinitializing Setup.
2019-05-31 21:32:03.557   Log closed.

注意吗?为什么将它安装到 Windows 文件夹中?

  

2019-05-31 21:32:03.360 Dest filename: C:\WINDOWS\CommunityTalks.chm

如何指定要实际安装文件的文件夹?

更新

我发现了有关使用自定义参数的类似问题。所以我将其更改为:

Source: "CommunityTalks.chm"; DestDir: "{param:InstallPath}"; Flags: ignoreversion

我将命令行从使用DIR调整为InstallPath,但是恕我直言DIR应该就足够了。


替代

我假设我可以使用此Pascal脚本,也许可以使用?然后,我不需要传递文件夹:

// Returns the path where the program was last installed
function GetPathInstalled( AppID: String ): String;
var
    sPrevPath: String;
begin
    sPrevPath := '';
    if not RegQueryStringValue( HKLM,
        'Software\Microsoft\Windows\CurrentVersion\Uninstall\'+AppID+'_is1',
        'Inno Setup: App Path', sPrevpath) then
        RegQueryStringValue( HKCU, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\'+AppID+'_is1' ,
                            'Inno Setup: App Path', sPrevpath);

    Result := sPrevPath;
end;

因为我知道应用程序ID。如果他们移动了程序或其他东西,传递它的好处将得到满足。但是我的问题仍然是关于DIR的失败。

1 个答案:

答案 0 :(得分:1)

引用CreateAppDir documentation

  

如果将其设置为no,则不会为该应用程序创建目录,选择目标位置向导页面将不会显示,并且 {{1} }目录常量等同于{app}目录常量