Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42225

Method for updating un-installed, 1 exe program with no extra files...

$
0
0
***EDIT: I just realized the code I added in was c# and this was the vb forum. I apologize for that mistake. However, this was more a discussion on methods than the actual code itself - so mods can move if need be...

I'm on the search to adapt a 1 exe, non-install program into an updateable program. I know the easiest way is ClickOnce and there is also using another exe as the updater and having that launch the program exe.

I think I came up with a suitable option, but as I keep pondering it, the more I keep second guessing myself. As of right now, I have a public dropbox with a txt file that has 1 line, the latest version of the program. The real program exe checks this txt file and reads the first line, and if it's different than the programs version, downloads an updater.exe file. The updater exe will then download the new client exe, overwriting the original one (which would be closed upon launching the updater exe). After, the new client exe launches and the updater closes...

I'll outline it a little below:
Code:

//here are the different ways of getting the executables path that I've found
string exePath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
string exePath = System.Reflection.Assembly.GetEntryAssembly()
string exePath = System.Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location );

//on loading/showing client form
using(WebClient wc = new WebClient())
        string theTextFile = wc.DownloadString("http://dl.dropbox.com/u/**/**.txt"); //sorry, not giving out url
if(theTextFile!=Properties.Settings.Default.version)
{
        //download updater
        WebClient webClient = new WebClient();
        //webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
        webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
        webClient.DownloadFileAsync(new Uri("http://dl.dropbox.com/u/**/**.exe"), updaterexepath); //updaterexepath is set to client's exe path
}
else
{
        //client up to date

}

private void Completed(object sender, AsyncCompletedEventArgs e)
{
        Process proc = Process.Start(Path.Combine(updaterexepath,**.exe));
        //close the client exe (this form)
}

On the updater form loading/shown, it basically runs the same way, downloading the new client exe, and on download complete, launches the new client exe while closing the updater form. On client load/shown, if it doesn't update, delete the updater exe...

Is this is a good way of doing an updating method without installing the program, using clickonce, or always having multiple exe's on the clients machines?

*The versions.txt and client/update exe's will not stay in dropbox but be housed on a file server later. This is only in testing the method...

Viewing all articles
Browse latest Browse all 42225

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>