2

Newbie question, let me try and make this as clear as possible. I have a program that needs to silently execute a msi package (well multiple but that's not the problem)

The MSI packages are contained in a folder located in the same directory as my program. I've given it a simple name of "InstallFiles" for the time being.

I'm not keen on using the full path name eg. C:\my program\another directory\another directory etc because it'll be put on multiple PC's, old and new, in which case the drive letter can change. So far I have:

install.StartInfo.FileName = "msiexec";
install.StartInfo.Arguments = "/i F:\\InstallFiles\\JRE.msi";
install.Start();
install.WaitForExit();

However, when its launched it only gives me the Windows Installer switch information and then terminates, how do I get it to run and how would I go about changing the file path?

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Keenan Molver
  • 25
  • 1
  • 1
  • 4
  • Take a look: [Application.StartupPath](http://msdn.microsoft.com/es-es/library/system.windows.forms.application.startuppath%28v=vs.80%29.aspx) – tttony Sep 16 '12 at 15:35

2 Answers2

2

use with the following switch:

/q[n|b|r|f]

    Sets user interface level
    n - No UI
    b - Basic UI
    r - Reduced UI

Check http://msdn.microsoft.com/en-us/library/windows/desktop/aa367988%28v=vs.85%29.aspx for detailed commandline options.

NileshChauhan
  • 5,469
  • 2
  • 29
  • 43
1

The executing of .msi file should be like .exe file that here is your answer : https://stackoverflow.com/a/12436300/359170

start the application with this code :

Process.Start("yourfile.msi"); 

and it don't need the full path, it adds current directory to the file name you written there.

But

System.IO.Directory.GetCurrentDirectory();

gets the current executed file directory. And you can get the file path by adding just the name of the file to it like this :

 string path = System.IO.Directory.GetCurrentDirectory() + "\\yourfile.msi";
Community
  • 1
  • 1
Hamed
  • 2,084
  • 6
  • 22
  • 42