Bonjour,

je créé un setup pour installer mon application.
le problème c'est que je ne peux pas lancer mon setup
si une autre version est déjà installé.
Je voudrai pouvoir desinstaller mon programme avant l'installation mais cela ne fonctionne que avec le meme setup.

voici ce que j'ai:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
 
[RunInstaller(true)]
    public partial class InstallerTest : System.Configuration.Install.Installer
    {
        public string AppName
        {
            get
            {
                return "donjons";
            }
        }
 
        public string UninstallString
        {
            get
            {
                if (Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") != null)
                {
                    string[] subKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall").GetSubKeyNames();
 
                    string path = string.Empty;
 
                    foreach (string key in subKey)
                    {
                        path = string.Format(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{0}", key);
                        if (Microsoft.Win32.Registry.LocalMachine.OpenSubKey(path).GetValue("DisplayName") != null
                            && Microsoft.Win32.Registry.LocalMachine.OpenSubKey(path).GetValue("DisplayName").ToString().ToLower() == AppName.ToLower())
                        {
                            return Microsoft.Win32.Registry.LocalMachine.OpenSubKey(path).GetValue("UninstallString").ToString().Replace("/I", "/X");
                        }
                    }
                }
                return null;
            }
        }
 
        public InstallerTest()
        {
            InitializeComponent();
 
            WriteToEventLog();
 
            this.
            this.BeforeInstall += new InstallEventHandler(InstallerTest_BeforeInstall);
            //this.AfterInstall += new InstallEventHandler(InstallerTest_AfterInstall);
            //this.Committing += new InstallEventHandler(InstallerTest_Committing);
            //this.Committed += new InstallEventHandler(InstallerTest_Committed);
        }
 
        private void InstallerTest_BeforeInstall(object sender, InstallEventArgs e)
        {
            new MsgBox("Before installation \n" + UninstallString, "Before install").ShowDialog();
 
            if (!string.IsNullOrWhiteSpace(UninstallString))
            {
                new MsgBox("début désinstallation", "uninstall").ShowDialog();
 
                string batchCode = string.Format("{0} /passive", UninstallString);
 
                ProcessStartInfo processInfo = new ProcessStartInfo("cmd.exe", "/c " + batchCode);
 
                processInfo.CreateNoWindow = true;
                processInfo.UseShellExecute = false;
 
                Process process = Process.Start(processInfo);
                process.WaitForExit();
 
                new MsgBox("Fin désinstallation", "uninstall").ShowDialog();
            }
        }
 
 
 
 
        private void WriteToEventLog()
        {
            System.Diagnostics.EventLog.WriteEntry("InstallerTest", "Installer class has been invoked");
        }
 
        void InstallerTest_Committed(object sender, InstallEventArgs e)
        {
            new MsgBox("Committed", "Committed").ShowDialog();
        }
 
        void InstallerTest_Committing(object sender, InstallEventArgs e)
        {
            new MsgBox("Committing", "Committing").ShowDialog();
        }
 
        void InstallerTest_AfterInstall(object sender, InstallEventArgs e)
        {
            new MsgBox("After installation", "After install").ShowDialog();
        }
    }
ce que je voudrai ce serai que la desinstallation se passe avant l'execution du setup mais je ne voit pas comment m'y prendre. Auriez-vous une solution ?
d'avance merci