Question How can my desktop app download and install another app?

Joined
Sep 16, 2023
Messages
20
Programming Experience
10+
WHAT I HAVE:
Visual Basic 2019, .NET Framework 4.6+, WinForms

MY ISSUE:

I want my desktop app to be able to, should it find that a secondary program (say, Skype for Desktop or some other freeware that my code invokes) not present on my system (that's relatively easy to determine), attempt to automatically download and install it. I can find nothing in the VS help files or on Microsoft's website for doing that, except for how to make my program download and install updates of itself; perhaps I'm not asking the question correctly. How does one programmatically download/install another application for use by mine, generally, speaking? (My code could fire up the user's browser at the proper website so he/she can install it manually, but that puts too much onus on the user--plus it also gives the user lattitude to do unrelated browser activity instead of the task at hand. I want to automate the search/download/install process!)

Please give any answers in VB.NET, as simply as possible, and ASAP.
 
Solution
That may be best, easiest, and safest. However:

In my program, I use the WebBrowser control to send users to specific pages and limit their navigation to pages reachable from the page's web site (that is, I don't let them "enter" and navigate to an arbitrary, unrelated site address to do "unrelated" stuff); that's because I want my program not to simply be a "no-holds-barred" browser-launcher, and for it to have a little control over things when users use the web for the program's purposes. The question is, how do I enable the download-and-install process--which on the browser involves the user selecting a destination file and opening it--to happen from within the WebBrowser control, as opposed to simply a blind...
The reason you can't find it is because there's nothing to find. There's no magic functionality that is specific to that. If you want to download a file, download a file. How you do it is not affected by what the file or file type is. There's plenty of information around about downloading files. Similarly, if you want to run an installer then you run it like you would any other file and there's plenty of information around about that too. There's no single repository out there for all the program installers you might want so it's up to you to find the appropriate download URL and store that in your app. It's also up to you to make sure that what your app contains remains up to date.

You also have the option of including prerequisites in your own app's installer. I'm sure that other installation tools are similar but, if you use ClickOnce or Setup projects in VS, there are a number of existing prerequisite packages that you can include in your installer and then they will be installed automatically when your app is if they are not already present. It is possible to create your own prerequisites for other app installers, but you should make sure that you're not breaking license terms by doing so, if you go down that route.
 
Just tell the user to do it, maybe send them to the download page to make life easier for them. This way, psychologically, they're fully consenting and on board with installing extra software rather than having a "hmm how did this get here" or "why does this app want to make changes to my computer?" moment
 
The reason you can't find it is because there's nothing to find. There's no magic functionality that is specific to that. If you want to download a file, download a file. How you do it is not affected by what the file or file type is. There's plenty of information around about downloading files. Similarly, if you want to run an installer then you run it like you would any other file and there's plenty of information around about that too. There's no single repository out there for all the program installers you might want so it's up to you to find the appropriate download URL and store that in your app. It's also up to you to make sure that what your app contains remains up to date.

You also have the option of including prerequisites in your own app's installer. I'm sure that other installation tools are similar but, if you use ClickOnce or Setup projects in VS, there are a number of existing prerequisite packages that you can include in your installer and then they will be installed automatically when your app is if they are not already present. It is possible to create your own prerequisites for other app installers, but you should make sure that you're not breaking license terms by doing so, if you go down that route.

So there is no general VS code tool that searches for software to download and install? Interesting. Of course, if I knew the download URL, then it downloading and installing would be straightforward with functionality I've already discovered--i.e., WebRequest and Process. What's the best way to find the URL for an installer? Most online searches direct me to manual-download sites--something puts the onus on the user--as opposed to the program--to figure out what version to download and then actually do so--not very helpful to the "casual user". Should I word my search differently (or use a different mechanism than a standard web search) to look for an app's downloadable installer's URL? Also, does anybody know how to find the URL for the Skype-for-Desktop installer?
 
Just tell the user to do it, maybe send them to the download page to make life easier for them. This way, psychologically, they're fully consenting and on board with installing extra software rather than having a "hmm how did this get here" or "why does this app want to make changes to my computer?" moment
That may be best, easiest, and safest. However:

In my program, I use the WebBrowser control to send users to specific pages and limit their navigation to pages reachable from the page's web site (that is, I don't let them "enter" and navigate to an arbitrary, unrelated site address to do "unrelated" stuff); that's because I want my program not to simply be a "no-holds-barred" browser-launcher, and for it to have a little control over things when users use the web for the program's purposes. The question is, how do I enable the download-and-install process--which on the browser involves the user selecting a destination file and opening it--to happen from within the WebBrowser control, as opposed to simply a blind browser launch?
 
That may be best, easiest, and safest. However:

In my program, I use the WebBrowser control to send users to specific pages and limit their navigation to pages reachable from the page's web site (that is, I don't let them "enter" and navigate to an arbitrary, unrelated site address to do "unrelated" stuff); that's because I want my program not to simply be a "no-holds-barred" browser-launcher, and for it to have a little control over things when users use the web for the program's purposes. The question is, how do I enable the download-and-install process--which on the browser involves the user selecting a destination file and opening it--to happen from within the WebBrowser control, as opposed to simply a blind browser launch?

Ultimately, the solution is to make a temporary test app with a WebBrowser (set to ignore scripting errors!) control that takes you to the download site. Then have the Navigating event track the URLs of each page reached so that you can determine which exact page URL physically triggers the download. When a page triggers a download, the process of downloading--and installing-- the application takes care of itself--provided you don't close the form before the download completes.

So, having determined the exact page that performs the download/install, create a form on your main app a form with a WebBrowser control hidden from view (say, off the visible part of the form) that when triggered takes you right to the URL of the page that performs that download (not the page that prompts you to do so!). Have visible on the form a button to Close the form--with a warning that clicking it while the download is in progress will abort it. Allow the form to be minimized or hidden while it works. If there's a way to determine on from your download folder that the download has been sucessfully happened, or if the subsequent installation has placed the app on your system someone, then your program can then safely close the form--and the Close button can instead be a Cancel button.

Your program should display a message box asking the user if they want to download and install the app, and if they say yes, then invoke the form to invoke the download, and then close it when the complete download or installation has been detected. The user has full consenting control over whether or not to install the app, with the option to cancel while download is in progress. The program, by searching for the app, can tell if the download and install was successful, and can then close the form if it isn't already closed.
 
Solution
Back
Top