0

Here is what i am trying to do ...

Download an exe from web Install it silently Run the downloaded exe and pass it an argument

The code I have is

import urllib.request
import shutil
import subprocess
import os
from os import system

url = "https://downloads.com/App.exe"
output_file = "C:\\files\App.exe"
with urllib.request.urlopen(url) as response, open(output_file, 'wb') as out_file:
    shutil.copyfileobj(response, out_file)

# Silent Install
subprocess.call("C:\\files\App.exe /SILENT ")


system("C:\\Program Files (x86)\\files\App.exe -ARG")

When i run it downloads the exe, installs the exe but then fails with this error when trying to exe the downloaded file

'C:/Program' is not recognized as an internal or external command,
operable program or batch file.
7
  • 1
    Post your actual code if you want us to diagnose it. Commented Mar 29, 2019 at 8:56
  • what do you mean ??????? I did! Commented Mar 29, 2019 at 8:57
  • 1
    Right. Then where does the 'C:/Program' is not recognized as an internal or external command error come from if no such path exists in your code? Commented Mar 29, 2019 at 8:59
  • Or in other words, what line did the error occur on? Commented Mar 29, 2019 at 9:00
  • updated ... Last line Commented Mar 29, 2019 at 9:02

2 Answers 2

1

Try to substitute:

system("C:\\Program Files (x86)\\files\App.exe -ARG")

by: subprocess.call("C:\\Program Files (x86)\\files\App.exe -ARG")

Sign up to request clarification or add additional context in comments.

Comments

0

Resolved using the below

import urllib.request
import shutil
import subprocess
import os
from os import system

url = "https://downloads.com/App.exe"
output_file = "C:\\files\App.exe"
with urllib.request.urlopen(url) as response, open(output_file, 'wb') as out_file:
    shutil.copyfileobj(response, out_file)

# Silent Install
subprocess.call("C:\\files\App.exe /SILENT ")

subprocess.call(['C:\\Program Files (x86)\\files\App.exe', '-ARG'], shell=True)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.