2011-08-26 8 views
2

Je suis en train d'écrire un InstallerClass en utilisant C# comme une action personnalisée pour mon installateur, et je peux courir avec succès un exe externe (installation) en utilisant le InstallerClass, mais lorsque je tente d'utiliser /quiet dans le InstallerClass, il ne pas installer l'exe. Mais je peux installer avec succès en mode silencieux en utilisant /quiet dans l'invite de commande.Installation silencieuse en utilisant C#

Y at-il une raison pour cela ou autrement comment installer en mode silencieux en utilisant C# ???

Edit:

Voici le code que j'utilise dans la méthode Commit (overriden):

Process p = new Process(); 
p.StartInfo.UseShellExecute = false; 
p.StartInfo.FileName = pathExternalInstaller; 
p.StartInfo.Arguments = "/quiet"; 
p.Start(); 

Merci

+0

s'il vous plaît montrer un code source - esp. la partie où vous appelez le fichier EXE externe pour l'installation. – Yahia

+0

@ Yahia: J'ai ajouté le code que j'ai utilisé ... –

+0

Avez-vous essayé (avec succès) d'exécuter le "programme d'installation externe" avec l'option '/ quiet' directement, par ex. à partir d'une invite de commande? –

Répondre

7

Voici ce que j'utilise pour faire un endroit calme installation et la désinstallation :

public static bool RunInstallMSI(string sMSIPath) 
    { 
     try 
     { 
      Console.WriteLine("Starting to install application"); 
      Process process = new Process(); 
      process.StartInfo.FileName = "msiexec.exe"; 
      process.StartInfo.Arguments = string.Format(" /qb /i \"{0}\" ALLUSERS=1", sMSIPath);  
      process.Start(); 
      process.WaitForExit(); 
      Console.WriteLine("Application installed successfully!"); 
      return true; //Return True if process ended successfully 
     } 
     catch 
     { 
      Console.WriteLine("There was a problem installing the application!"); 
      return false; //Return False if process ended unsuccessfully 
     } 
    } 

    public static bool RunUninstallMSI(string guid) 
    { 
     try 
     { 
      Console.WriteLine("Starting to uninstall application"); 
      ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe", string.Format("/c start /MIN /wait msiexec.exe /x {0} /quiet", guid)); 
      startInfo.WindowStyle = ProcessWindowStyle.Hidden; 
      Process process = Process.Start(startInfo); 
      process.WaitForExit(); 
      Console.WriteLine("Application uninstalled successfully!"); 
      return true; //Return True if process ended successfully 
     } 
     catch 
     { 
      Console.WriteLine("There was a problem uninstalling the application!"); 
      return false; //Return False if process ended unsuccessfully 
     } 
    } 
+0

J'ai appelé 'RunInstallMSI' dans le remplacement pour Commit dans le InstallerClass, mais il dit qu'une autre installation est déjà en cours et ne permet pas d'installer l'exe externe lors de l'installation de l'application .... une raison quelconque ou une solution? –

+0

http://support.microsoft.com/kb/236456 –

1

P Cela fonctionne pour moi :)

 Process process = new Process(); 
     process.StartInfo.FileName = @"C:\PATH\Setup.exe"; 
     process.StartInfo.Arguments = "/quiet"; 
     process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 
     process.Start(); 
     process.WaitForExit(); 
Questions connexes