#To define a particular parameter, replace the 'parameterName' inside itsm.getParameter('parameterName') with that parameter's name
URL = itsm.getParameter('URL') #Please provide the URL to download file eg: https://teamsecurityllc.com/download/WebTitan_windows.msi
batch_file_content = itsm.getParameter('batch_file_content') #Please provide the batch file content eg: /quiet /qb WTC_SERVER_URL=http://52.21.114.180:8080 DNS_RESOLVER=34.197.170.153 CUSTOMER_EMAIL=tim.elliott@teamsecurityllc.com CUSTOMER_PASSWORD=4?;BG2`we)\ZWMM7

def Download(URL,batch_file_content):
    import urllib2
    import os
    import time
    print "Download started"
    fileName =URL.split('/')[-1]
    src_path=os.environ['ProgramData']
    fp = os.path.join(src_path, fileName)
    request = urllib2.Request(URL, headers={'User-Agent' : "Magic Browser"})
    parsed = urllib2.urlopen(request)
    if os.path.exists(src_path):
        print "Path already exists"
    if not os.path.exists(src_path):
        os.makedirs(src_path)
        print "Path created"
    with open(fp, 'wb') as f:
        while True:
            chunk=parsed.read(100*1000*1000)
            if chunk:
                f.write(chunk)
            else:
                break
    print "The file downloaded successfully in specified path"+fp
    try:
        print'Downloaded Application %s Installation Started'%fileName
        os.popen("msiexec /i  %s %s" %(fp, batch_file_content)).read()
        time.sleep(20)
        print '%s Application Successfully Installed'%fileName
    except:
        return 'No : '+fp+' is exist'
    os.remove(fp)
	
Download(URL,batch_file_content)