jeudi 26 juillet 2018

Why is this "If-Else if- else" statement not working for the process.start?

I am struggling to see why this if-Else if- Else statement is not working.

        string JPRO_8_5_0 = @"C:\ProgramData\Package Cache\{0809190b-37e7-4852-9f0c-e183636739ba}\JproSetup.exe";
        string JPRO_8_4_0 = @"C:\ProgramData\Package Cache\{270ce95e-5e84-4b6a-8d58-f8905b0a3cfc}\JproSetup.exe";


        if (JPRO_8_5_0 != null)
        {
            Process a = new Process();
            a.StartInfo.FileName = JPRO_8_5_0;
            a.StartInfo.Arguments = "/uninstall /quiet";
            a.Start();
        }
       else if (JPRO_8_4_0 != null)
        {
            Process b = new Process();
            b.StartInfo.FileName = JPRO_8_4_0;
            b.StartInfo.Arguments = "/uninstall /quiet";
            b.Start();
        }
       else
        {

        }

So basically what I am needing to do is have the program check the files listed in the strings, and if it is there, run the silent installer.

I know the first silent installer will go through if I have that file installed. However, I need it to check for multiple versions as we have around 20 different versions out there I need to be able to remove at any point.

When it goes to check, if the JPRO_8_5_0 is not there, it will panic and say the item is not found (yeah, no duh). I want this to skip whatever versions are not found and move onto the next version to check.

Any advice on why this is not working for me?

Aucun commentaire:

Enregistrer un commentaire