I have a URL which is a download link to a software.exe file. The intended operation is to use Python 3 to download the said file and then do a silent installation.
import ssl
from urllib.parse import urlparse
import requests
#convert to string
url = str(url)
#convert ftp download path to http and remove chars to make it downloadable
httpurl = re.sub("ftp://","https://",url)
print("url is: " + url)
#function to break file name from the full path
def split(downloadurl):
p,downloadexename = os.path.split(downloadurl)
return [downloadexename]
#Remove all the unnecessary stuff you don't need
downloadurl = httpurl.replace("'","").replace(',','').replace(":2100/FTP Folders/Software","").replace(" ","%20").strip("(").strip(")")
print("Download URL is: "+downloadurl)
down_name = os.path.basename(downloadurl)
down_dir = r"C:\Desktop"
#Create folder if it doesn't exist for download as required
if not os.path.exists(down_dir):
os.makedirs(down_dir)
full_path = os.path.join(down_dir, down_name)
# Silent Install
subprocess.call([full_path, '/Silent'], shell=True)
It depends on what kind of installer the .exe
is, but there is a high chance it already has the ability to install silently. For example, InnoSetup installers (a very common type) use the parameter /SILENT
. If you don't know the installer type, you may try running the .exe
with different variants of /s
, /S
, /SILENT
etc. -- or some variants of /?
, --help
to show command line usage.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.