kkkwj
Posts: 88
Joined: Thu Mar 01, 2007 10:45 pm

Provide C# code to integrate updater with C# application

Tue Mar 13, 2007 2:44 am

Hi, I see that you provide C++ and Java code to integrate the installer with applications. But there is no C# example. Since C# is the new standard language for .NET, it would be useful if you could provide a C# example for how to integrate the updater into a C# program.

gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact:  Website

Tue Mar 13, 2007 8:43 am

Hi,

We shall consider to add this is a future version of Advanced Installer. I add this on our TODO list. Thank you for your suggestion.

Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com

kkkwj
Posts: 88
Joined: Thu Mar 01, 2007 10:45 pm

Thu Apr 05, 2007 3:13 pm

Hi, I wonder if you have some C# code around for integrating the updater into an application? It did not make it into the most recent release, so I'm wondering if you could just append some code to this thread to get me going in the meantime... Thanks

gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact:  Website

Tue Apr 10, 2007 12:51 pm

Hi,

Here is a small sample:

Code: Select all

using System.Diagnostics;

...

//Declare and instantiate a new process component.
System.Diagnostics.Process process;
process = new System.Diagnostics.Process();

System.Diagnostics.Process.Start("updater.exe", "/checknow");
process.Close();
The updater must be located next to the builded EXE file.

Hope this helps.

Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com

kkkwj
Posts: 88
Joined: Thu Mar 01, 2007 10:45 pm

Tue Apr 10, 2007 3:50 pm

Thanks! You make it look so simple compared to the documented c++ version... I'll try this out now that I have an example to follow.

kkkwj
Posts: 88
Joined: Thu Mar 01, 2007 10:45 pm

Fri Apr 20, 2007 4:11 pm

Hi, here is the code that I added to my Main.exe C# assembly, to check for upgrades to my application. The code is based on the code sample you provided in this thread.

The problem is that this code throws up a dialog box ("Your software is up to date OK?") every time it checks for upgrades, forcing me to click OK to get rid of the dialog. I would rather have the program just do the check, and NOT throw up a dialog box if the app is up to date.

Can I do that? If so, how? (The /silent option doesn't seem to do that.)

Thanks
kj


Code: Select all

    // check for updates on the website
    // The updater.exe program must be in the APPDIR sitting next to main.exe
    //Declare and instantiate a new process component. 
    string path =  "updater.exe";

    if (File.Exists (path)) {
        System.Diagnostics.Process process;
        process = new System.Diagnostics.Process ();
        System.Diagnostics.Process.Start (path, "/checknow /silent");
        process.Close ();
    }
    else {
        MessageBox.Show ("Can't see the updater.exe program");
    }

gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact:  Website

Mon Apr 23, 2007 8:06 am

Hi,

To check silently for updates use /silent command line switch for updater. So use this line to call the updater:

Code: Select all

System.Diagnostics.Process.Start (path, "/silent");
You can read more about command line switches here:
http://www.advancedinstaller.com/user-g ... dater.html

Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com

kkkwj
Posts: 88
Joined: Thu Mar 01, 2007 10:45 pm

Mon Apr 23, 2007 9:18 pm

If you consider my code provided above, I did include the /silent argument. Are you saying that /silent must be used alone? Maybe /silent implies both /checknow and /silent?

gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact:  Website

Tue Apr 24, 2007 8:35 am

Hi,

All command line options (like: /checknow, /silent, /silentall, etc) of the updater are made to be used alone. So to check silently for updates use /silent option.

Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com

kkkwj
Posts: 88
Joined: Thu Mar 01, 2007 10:45 pm

Thu Apr 26, 2007 9:36 pm

Thanks for the confirmation. Now I'm off to the races!

(You might consider adding this "use these arguments alone" info to the doc, when you add in the C# code to the doc. That's where I went first, before I bothered you in the forum... :-)

AI is a really nice product. And your forum support is really good too.

AI_New_User
Posts: 25
Joined: Thu Aug 26, 2021 4:57 pm

Re: Provide C# code to integrate updater with C# application

Sat Aug 28, 2021 1:47 pm

What does code look like when you want to check for "/justcheck"? The documentation says it returns 0. How would you check that in C#?

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Provide C# code to integrate updater with C# application

Tue Aug 31, 2021 8:15 am

What does code look like when you want to check for "/justcheck"? The documentation says it returns 0. How would you check that in C#?
Hi,

To use "/justcheck" in C# you can use the following code:

Code: Select all

        private void button2_Click(object sender, EventArgs e)
        {
            Process process = Process.Start(updaterModulePath, "/justcheck");
            process.WaitForExit();
           
            if (process.ExitCode == 0)
            {
                MessageBox.Show("Update found!");
                process.Close();
            }
        }

In the below screenshot you can see the output, if the "/justcheck" command finds updates and the ExitCode is 0, then the message box is prompted.
updater_justcheck.png
updater_justcheck.png (5.4KiB)Viewed 52226 times
This is an example of how to use the return code, feel free to adapt the code to your scenario.

Hope this helps! If you have any other questions, please don't hesitate to contact us.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube


Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Provide C# code to integrate updater with C# application

Tue Aug 31, 2021 1:35 pm

You are always welcome!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”