Wix:从文件路径获取目录 [英] Wix: Get Directory from File Path

查看:126
本文介绍了Wix:从文件路径获取目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Adobe Illustrator创建一个插件,并试图使用WiX为其创建安装程序.因此,为了使插件安装在正确的位置,我正在阅读注册表,以查找Illustrator的最新版本,然后找到该Illustrator exe的文件路径.一切正常,并给了我"C:\Program Files\Adobe\Illustrator CC 2018\Support Files\Contents\Windows\Illustrator.exe"(我已经检查过,如果您选择将其安装在其他位置,则此路径反映了这一点).插件安装在"C:\Program Files\Adobe\Illustrator CC 2018\Plug-ins"中.

I'm creating a plugin for Adobe Illustrator and I'm attempting to make an installer for it using WiX. So in order to get the plugin to install in the correct location I am reading the registry to find the most up to date version of illustrator and then find the file path to that Illustrator exe. This all works fine and gives me "C:\Program Files\Adobe\Illustrator CC 2018\Support Files\Contents\Windows\Illustrator.exe" (I've checked and if you choose to install it elsewhere this path reflects that). Plugins are installed in "C:\Program Files\Adobe\Illustrator CC 2018\Plug-ins".

所以我现在要尝试的是使用exe的路径来获取Plug-ins文件夹的相对路径.在WiX中有一种简单的方法吗?

So what I'm now trying to do is using the path to the exe get a relative path to the Plug-ins folder. Is there an easy way to do this in WiX?

我尝试使用

<CustomAction Id="SETDIRECTORY" Property="PLUGINFOLDER" Value="[ILLUSTRATOREXEPATH]..\..\..\Plug-ins" />

但这会引发错误,表明..是无效字符

but this throws an error saying that .. is an invalid character

我知道设法通过使用RegistrySearch Type"file"来获取文件的目录,这给了我"C:\Program Files\Adobe\Illustrator CC 2018\Support Files\Contents\Windows\",但是如果不使用脚本,就无法解决如何获取父目录(我不想诉诸的东西,因为它显然会引起反病毒问题.

I've know managed to work out how to get the directory of the file by using the RegistrySearch Type "file", giving me "C:\Program Files\Adobe\Illustrator CC 2018\Support Files\Contents\Windows\" but can't work out how to get the parent directory without using a script (something I don't want to have to resort to as it can apparently cause issues with anti virus).

推荐答案

您是否通过注册表 INI文件或其他设置文件搜索了>在磁盘上确定plugins文件夹的完整路径是否写在任何地方并可以使用?

Did you search through the registry or INI files or other settings files on disk to determine if the full path to the plugins folder is written anywhere and ready for use?

很有可能将完整路径写在某个地方,或者您会找到一个基本文件夹,您可以按照已经采用的方式添加子文件夹,但是没有导致您出现问题的父目录部分.

There are good chances the full path is written somewhere, or you will find a base folder that you can just add sub folders to in the fashion you already did, but without the parent directory sections that cause you problems.

除了简单地浏览或搜索注册表和磁盘以寻找线索外,检查原始安装MSI还可以提供有关此路径写入位置的线索.查看IniFile tableRegistry tableEnvironment table等.

In addition to simply looking through or searching the registry and disk for clues, inspecting the original installation MSI can also provide clues as to where this path is written. Look in the IniFile table, Registry table, Environment table and similar.

如果您没有用于细读MSI文件的工具,则可能会看到以下答案(朝下-免费工具列表):

If you don't have a tool to peruse MSI files with, perhaps see this answer (towards bottom - list of free tools): How can I compare the content of two (or more) MSI files?

如果您没有原始安装程序,我会附上技术说明.在安装过程中,将在您的系统上制作安装MSI的副本.您可以打开此文件以搜索设置.

I will throw in a tech-note in case you don't have the original installer. During installation a copy of the installation MSI will be made on your system. You can open this file to search for settings.

此VBScript代码段应显示Adobe产品的所有缓存包.将其放在桌面上的* .vbs文件中,然后运行它.弹出一个带有任何结果的消息框(如果未找到任何内容,则显示空白).打开指定的MSI路径-并对此文件不做任何更改! (或者更好的方法是,将其复制到桌面并从那里打开).

This VBScript snippet should show all cached packages for Adobe products. Put it in a *.vbs file on your desktop and just run it. A message box pops up with any result (blank if nothing is found). Open the MSI path specified - and make no changes to this file! (or better yet, make a copy of it to the desktop and open it from there).

On Error Resume Next ' we ignore all errors
Set installer = CreateObject("WindowsInstaller.Installer")
Dim adobeproducts

For Each product In installer.ProductsEx("", "", 7)

   name = product.InstallProperty("ProductName")
   cachedpackage = product.InstallProperty("LocalPackage")

   If InStr(LCase(name), "adobe") Then
      adobeproducts = adobeproducts + name & ", " & cachedpackage & vbCrLf & vbCrLf
   End If

Next

MsgBox adobeproducts

这篇关于Wix:从文件路径获取目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆