简体   繁体   中英

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:

E:\\Data\\Progamming\\DotNET\\Xinvitro\\Code\\SetupXinvitroAC\\Debug. Then I copy file Drivers.exe to same folder.

I goto the custom actions viewer, and select the properties for your custom action. then enter the following as the CustomActionData parameter:

/TARGETDIR="[TARGETDIR]\\"

in project I add Intaller file. I overwirite method 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.

I want ask how I get path like "E:\\Data\\Progamming\\DotNET\\Xinvitro\\Code\\SetupXinvitroAC\\Debug" to run file Drivers.exe. Thanks.

To receive path from where you launch installer use:
- MSI - SourceDir property
- EXE (InstallShield) - SETUPEXEDIR property.

I guess, SourceDir will also work for bootstrapped EXEs (with help of WiX).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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