从使用Wix制作的MSI生成文本
Generate text from MSI made using Wix
这听起来可能是一个愚蠢的问题,但我想处理使用 Wix 生成的 msi 文件的参数。我已经在VS2010中开发了Visual C++程序,例如
msiexec /i setup.exe IP="192.168.2.1" PORT="9999"
我想访问这些参数 IP 和 PORT 并将它们写入文本文件中,如下所示:
{
"IP":"192.168.2.1",
"PORT":"9999"
}
这在Wix中可能吗?如果不是,有什么办法
我相信
有一种方法可以做到这一点,尽管我自己还没有这样做。
如果将参数传递给 msiexec,如下所示:
msiexec /i setup.exe CUSTOMPROPIP="192.168.1.1" CUSTOMPROPPORT="9999"
然后,应在 msi 包随后可以分析的属性列表中设置该属性。 然后,您可以创建一个自定义操作来处理这些值,并且可以将文件写入磁盘。
<Binary Id="SetupCA" SourceFile="SetupCA.CA.dll" />
<CustomAction Id="WRITEFILETODISK" Execute="immediate" BinaryKey="SetupCA" DllEntry="WriteFileToDisk" />
请确保在安装序列中具有此自定义操作...
<InstallExecuteSequence>
<Custom Action="WRITEFILETODISK" Sequence="2" />
...
</InstallExecuteSequence>
您将需要一个自定义操作项目来创建此 SetupCA.CA.dll。 自定义操作的代码如下所示:
namespace SetupCA
{
public class CustomActions
{
[CustomAction]
public static ActionResult WriteFileToDisk(Session session)
{
session.Log("Begin WriteFileToDisk"); // This is useful to see when it is firing through the log file created during install with /l*vx parameter in msiexec
// Do work here...
string ipaddress = session["CUSTOMPROPIP"];
string ipport = session["CUSTOMPROPPORT"];
session.Log("Ending WriteFileToDisk");
return ActionResult.Success;
}
}
}
相关文章:
- 文本文件中的单词链表
- 从命令行c++发送文本文件名
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 2D数组来自文本输入,中间有空格
- 如何将内容数组写入文本文件?
- 无法通过空白将文本文件行分隔为矢量
- 我正在使用嵌套的while循环来解析具有多行的文本文件,但由于某种原因,它只通过第一行,我不知道为什么
- C++将文本文件中的数据读取到结构数组中
- 在指针的帮助下,文本文件中单词的频率
- 将字符指针十六进制转换为字符串并保存在文本文件C++中
- 将值从二维数组输出到文本文件
- 如何在c++中从文本文件中逐行读取整数
- 如何创建一个QTableWidgetItem,用长文本右对齐,左边有省略号
- 从文本文件中读取时钟时间和事件时间并进行处理
- 如何从文本文件中读取值和数组
- 如何在C++中确定文本文件中的元素是字符还是数字
- 如何根据单词在文本中出现的概率输出单词
- 如何在C++中用std::cout正确显示带十六进制的字符串文本
- C++试图读取一个文件并输出到另一个文本文件
- 从使用Wix制作的MSI生成文本