Download and install any application

This script will download and install any program that has silent install options. You need to supply url, app name, directory to save to, directory will be created if it doesn’t exist, and silent install options. The downloaded file will be deleted on completion.


import urllib2, subprocess, os, sys, shutil

url = 'http://www.thewebsomewhere.com/yourapp.ext'
appname = 'savedappname.exe'
filedirectory = "directory/to/save/to"

options1 = '-yourswitch1'
options2 = '/yourswitch2'

drive = os.path.splitdrive(sys.executable)[0] + os.sep
directory = os.path.join(drive, filedirectory)

if not os.path.isdir(directory):
    os.makedirs(directory)

installapplication = os.path.join(directory, appname)
getfile = urllib2.urlopen(url)
with open(installapplication, 'wb') as savefile:
    shutil.copyfileobj(getfile, savefile)

process = subprocess.Popen([ installapplication, options1, options2 ],stdout=subprocess.PIPE)
for line in iter(process.stdout.readline,''):
    print line.rstrip();        
        
os.remove(installapplication)

Can you modify this to check if the software already exist and if not download and install?

This would be helpful when adding workstations to a clients network. If the required software for the client is not installed by the technician, then the system will install it. For example, Comodo Security, a necessary browser such as FireFox, and so on.

Good idea.

Hi @rmorton

Yes sure , we will update you once the script is ready

Thank you. I think this will be an asset to the community.

We offer Script Writing service for anyone who need it and do so for free. Any script any time…for free…please use it.

Hi @rmorton,

Please use the script https://forum.mspconsortium.com/forum/script-library/8752-check-application-installed-if-not-download-and-install-it to get checking before downloading and installing any application

Thank you.