简体   繁体   English

如何在自定义操作中获取路径文件安装程序

[英]How to get path file installer on custom action

I have problem about create setup file . 我有关于创建安装文件的问题。 I have project winform, after build solution I have 2 files setup.exe and SetupXinvitroAC.msi contained in folder: 我有项目winform,在构建解决方案后,我的文件夹中包含2个文件setup.exe和SetupXinvitroAC.msi:

E:\\Data\\Progamming\\DotNET\\Xinvitro\\Code\\SetupXinvitroAC\\Debug. E:\\ DATA \\预设电台\\ DOTNET \\ Xinvitro \\代码\\ SetupXinvitroAC \\调试。 Then I copy file Drivers.exe to same folder. 然后,我将文件Drivers.exe复制到同一文件夹。

I goto the custom actions viewer, and select the properties for your custom action. 我转到自定义操作查看器,然后选择自定义操作的属性。 then enter the following as the CustomActionData parameter: 然后输入以下内容作为CustomActionData参数:

/TARGETDIR="[TARGETDIR]\\" / TARGETDIR = “[TARGETDIR] \\”

in project I add Intaller file. 在项目中,我添加了Intaller文件。 I overwirite method OnBeforeInstall 我重写了方法OnBeforeInstall

protected override void OnBeforeInstall(IDictionary savedState)
{
      base.OnBeforeInstall(savedState);
      if (!System.IO.File.Exists(@"C:\Windows\twain_32\Scanner\AVA6PlusG\AVA6PlusG.ds"))
     {
       string path = Context.Parameters["TARGETDIR"];
       TextWriter tw = new StreamWriter(@"C:\text.txt");
       tw.WriteLine(path);
       tw.Close();
       Process.Start( path + "Drivers.exe");     
       //I expect it will is Process.Start(   "E:\Data\Progamming\DotNET\Xinvitro\Code\SetupXinvitroAC\Debug\Drivers.exe");           
     }
}

But after installed, I open text.txt file it printed 'C:\\Program Files (x86)\\catvangsolution\\Xinvitro\\' not like I wanted, this is folder I install to. 但是安装后,我打开text.txt文件并打印了“ C:\\ Program Files(x86)\\ catvangsolution \\ Xinvitro \\”,它不是我想要的,这是我安装到的文件夹。

I want ask how I get path like "E:\\Data\\Progamming\\DotNET\\Xinvitro\\Code\\SetupXinvitroAC\\Debug" to run file Drivers.exe. 我想问一下如何获取诸如"E:\\Data\\Progamming\\DotNET\\Xinvitro\\Code\\SetupXinvitroAC\\Debug"来运行Drivers.exe文件。 Thanks. 谢谢。

To receive path from where you launch installer use: 要从启动安装程序的位置接收路径,请使用:
- MSI - SourceDir property -MSI - SourceDir属性
- EXE (InstallShield) - SETUPEXEDIR property. -EXE(InstallShield) -SETUPEXEDIR属性。

I guess, SourceDir will also work for bootstrapped EXEs (with help of WiX). 我猜想,SourceDir也可以用于自举的EXE(借助WiX)。

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

相关问题 (Wix 安装程序)如何包含自定义操作依赖项 - (Wix installer) how to include custom action dependency 如何在Windows Installer中更改自定义文件夹的路径? - How to change the path of custom folder in windows installer? 安装程序自定义操作不起作用 - Installer Custom action not working 如何在Windows安装程序的自定义操作中获取当前用户名? - How do I get the current users name in a custom action for windows installer? 如何调用高级安装程序中附加的.exe文件的先决条件C#自定义操作 - how to Invoke .exe file attached inside Advanced installer Prerequisite C# custom action 通过高级安装程序中的自定义操作将文件放入APPDIR - Place a file in APPDIR from a Custom Action in Advanced Installer 更新 <appname> 自定义安装程序类操作中的.config文件 - Updating <appname>.config file from an Custom Installer Class Action 向WiX安装程序添加自定义操作 - Adding Custom Action to WiX Installer 如何在Advanced Installer中加密连接字符串(13.3)自定义操作 - How to encrypt your Connection String in Advanced Installer (13.3) Custom Action 如何在 Visual Studio 2010 中为 c# 安装程序编写自定义操作? - how to write custom action for a c# installer in visual studio 2010?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM