0

I'm running a C# custom action (just a class library) that gets called from an InstallShield installer and I need access to the folder where the .exe was launched from. I've tried:

Directory.GetCurrentDirectory()
Environment.CurrentDirectory()
Application.StartupPath
Application.ExecutablePath

and they all return c:\windows\syswow64 - not the folder where the .exe was launched from. I'm guessing this is because the .dll is embedded in the .msi and that gets extracted to c:\windows\syswow64 (although it's hard to imagine that it really gets extracted there).

That's really all you need to know, but if you want more, I'm uninstalling prior versions that were written as InstallScript MSI projects and to uninstall them silently you need to provide "response files" (you'll need a Flexera account to follow that link), but it basically says that you need to "record" your uninstall actions into a response file and then pass that file to the msiexec uninstall using the syntax: setup.exe /s /f1"response file name". These response files are located in the installer folder and that's why I need to know what that folder is. Anyone know of a way to get a reference to this folder?

Ben_G
  • 770
  • 2
  • 8
  • 30
  • Look at: https://stackoverflow.com/questions/38071639/c-sharp-get-assembly-executable-directory – Flydog57 Dec 29 '18 at 00:03
  • 1
    This is not a duplicate of https://stackoverflow.com/q/38071639. The installation bootstrap (native) is loading a managed assembly, and the asker wants to know where the bootstrap was sitting. For that you have to query the bootstrap or the installation. See instead the SETUPEXEDIR property (if the installscript-msi tag is correct; use PACKAGE_LOCATION if pure InstallScript) as described on the correct duplicate https://stackoverflow.com/q/47987559. – Michael Urman Dec 29 '18 at 03:56
  • Thanks Michael. SETUPEXEDIR did the trick. – Ben_G Jan 03 '19 at 18:30

0 Answers0