简体   繁体   English

获取目录设置安装盾

[英]Get dir setup install shield

I want get dir my setup create by install shield. 我想通过安装盾获得我的安装程序创建的目录。 I use command parametter Setup.exe /path=[SETUPEXEDIR]\\log.txt My setup location is Desktop\\myapp\\Setup.exe When use [SETUPEXEDIR] return temp folder I want when use [SETUPEXEDIR] return me my Setup.exe location. 我使用命令参数Setup.exe /path=[SETUPEXEDIR]\\log.txt我的安装位置是Desktop\\myapp\\Setup.exe当使用[SETUPEXEDIR]返回临时文件夹时我想要使用[SETUPEXEDIR]时返回我的Setup.exe位置。

I use installshield 2016 version 23 SP 2. I use MSI Script. 我使用installshield 2016版本23 SP2。我使用MSI脚本。

I want get location and use in command parameter prerequisites. 我想获取位置并在命令参数先决条件中使用。

A little hard to comprehend exactly what you are asking, but as far as I understand you want to know the location where setup.exe is running from? 确切理解您的要求有点困难,但是据我了解,您想知道setup.exe的运行位置?

Variables 变数

  • The first question is: what version of Installshield are you using? 一个问题是:您使用的是什么版本的Installshield

  • The second question is: are you using Basic MSI or Installscript MSI ? 第二个问题是:您正在使用Basic MSI还是Installscript MSI

  • The third question is: what type of release media are you using? 第三个问题是:您使用哪种类型的发布媒体

  • There may be more relevant questions... 可能还有其他相关问题...

A word to the wise : if you are indeed using Installscript MSI you should know that it is a very buggy type of project, and you should seriously consider switching to Basic MSI to save yourself grief. 明智的一句话 :如果您确实在使用Installscript MSI,则应该知道它是一个非常有缺陷的项目类型,并且应该认真考虑改用Basic MSI来避免麻烦。 I can provide more information on this if you like. 如果您愿意,我可以提供更多信息。 I had to abandon Installscript MSI entirely to make my deployment problems go away. 我不得不完全放弃Installscript MSI,以消除部署问题。

Installshield Properties Installshield属性

It seems different versions of Installshield may behave differently and feature varying support for these folder properties / variables. 似乎不同版本的Installshield的行为可能有所不同,并且对这些文件夹属性/变量的支持功能也有所不同。 It also seems the properties may not work with all types of release media. 似乎该属性可能不适用于所有类型的发行媒体。 And finally they may only work in Basic MSI or Installscript MSI respectively. 最后,它们可能分别只能在Basic MSI或Installscript MSI中工作。 The properties I have found are: PACKAGE_LOCATION , SETUPEXEDIR and SRCDIR . 我发现的属性是: PACKAGE_LOCATIONSETUPEXEDIRSRCDIR There also appears to be an Installscript method called GetCurrentDir() available in recent versions of Installshield, but the documentation warns about using it (see link). 在最新版本的Installshield中,似乎还存在一个称为GetCurrentDir()的Installscript方法,但是文档警告有关使用该方法的信息(请参阅链接)。

Please visit the links above in sequence and read in detail about each property's (or method's) limitations . 请按顺序访问上面的链接,并详细阅读每个属性(或方法)的限制 It is very important that you use the option (if any) that matches your requirements and scenario. 使用与需求和方案相匹配的选项(如果有)非常重要。 For example PACKAGE_LOCATION works only for Installscript MSIs, SETUPEXEDIR is set by Setup.exe. 例如,PACKAGE_LOCATION仅适用于Installscript MSI,SETUPEXEDIR由Setup.exe设置。 If the end user runs the .msi package directly, SETUPEXEDIR is not set. 如果最终用户直接运行.msi程序包,则未设置SETUPEXEDIR。

MSI Built-in Property MSI内置属性

It seems to me that getting the built-in MSI property SourceDir might be an option to try. 在我看来,尝试获取内置的MSI属性SourceDir可能是一个选择。 My quick test indicates that it works for both InstallScript and Basic MSI. 我的快速测试表明它同时适用于InstallScript和Basic MSI。 However, I do not know if this works for all versions of Windows Installer. 但是,我不知道这是否适用于所有版本的Windows Installer。 Please test on various Windows versions to be sure. 请确保在各种Windows版本上进行测试。

You should also be aware of the potential problem using SourceDir which is described in the documentation for SETUPEXEDIR . 您还应该注意使用SourceDir的潜在问题,该问题在SETUPEXEDIR的文档中进行了描述。 This goes for setups that are compiled into a single, compressed setup.exe containing all files - this launcher will extract the MSI file to a temp location and run from there. 这适用于编译成包含所有文件的单个压缩setup.exe的安装程序-此启动器会将MSI文件提取到临时位置并从那里运行。 When I tried with an uncompressed network image it worked fine to use SourceDir. 当我尝试使用未压缩的网络映像时,使用SourceDir可以正常工作。

Finally, if you use a setup.exe to compress all files and enable the caching of the MSI on the system, then you will be running from somewhere inside: C:\\WINDOWS\\Downloaded Installations\\{GUID}\\ . 最后,如果您使用setup.exe压缩所有文件并启用系统上MSI的缓存,那么您将在以下位置运行: C:\\WINDOWS\\Downloaded Installations\\{GUID}\\

All of this could be different on newer versions of Installshield. 在更高版本的Installshield中,所有这些可能都不同。 I am testing with an ancient version I have available. 我正在使用可用的旧版本进行测试。 Please test thoroughly on your version. 请在您的版本上进行彻底测试。

I should also mention the OriginalDatabase built-in MSI property. 我还应该提到OriginalDatabase内置的MSI属性。 Check the link for documentation on how it will be set. 检查链接以获取有关如何设置它的文档。

Some links: 一些链接:

Installscript Function For Testing Installscript测试功能

And just for reference, here is a quick and dirty function to test these properties from an Installshield custom action (this is for other people who may find this without having tested as much as you): 仅供参考,这是一个快速且肮脏的功能,可通过Installshield自定义操作来测试这些属性(这适用​​于其他人,他们可能在没有进行尽可能多的测试的情况下就发现了此属性):

function TestFolderProperties(hMSI)   
     STRING svName;
     NUMBER nvSize;
begin             

    // MSI properties
    nvSize = 256;
    MsiGetProperty (hMSI, "SETUPEXEDIR", svName, nvSize);
    MessageBox ("SETUPEXEDIR: " + svName, INFORMATION);
    MsiGetProperty (hMSI, "SourceDir", svName, nvSize);
    MessageBox ("SourceDir: " + svName, INFORMATION);
    MsiGetProperty (hMSI, "OriginalDatabase", svName, nvSize);
    MessageBox ("OriginalDatabase: " + svName, INFORMATION);

    // System Variables
    MessageBox ("SRCDIR: " + SRCDIR, INFORMATION);
    // PACKAGE_LOCATION is not available in my version of Installshield, enable and test 
    //MessageBox ("PACKAGE_LOCATION: " + PACKAGE_LOCATION, INFORMATION);
end;

Remember to add the export to the top of the setup.rul file: 请记住将导出添加到setup.rul文件的顶部:

export prototype TestFolderProperties(HWND);  

Test compile to verify, and then create an Installscript custom action and put it in a sequence. 测试编译以进行验证,然后创建一个Installscript自定义操作并将其放入序列中。 Make "Return Processing" Synchronous (Ignores exit code) for the custom action. 使自定义操作的“返回处理”同步(忽略退出代码)。 I put it right before InstallFinalize in the sequence, using immediate mode execution. 我使用立即模式执行将其放在序列的InstallFinalize之前。 Rebuild your release and run it. 重建您的发行版并运行它。 Try different release build configurations (msi with external source files, MSI only with compressed files inside, setup.exe launcher with external files, setup.exe with all files compressed inside, setup.exe with caching, setup.exe without caching, etc... the behavior might be different). 尝试使用不同的发行版本配置(带有外部源文件的msi,仅带内部压缩文件的MSI,带外部文件的setup.exe启动器,带内部所有压缩文件的setup.exe,带缓存的setup.exe,不带缓存的setup.exe等)。 ..行为可能有所不同)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM