Reputation: 99
I'm trying to write a bit of code to allow me to open up an exe file within Python, but I don't know the general way to make it properly. I would think that the code would look something like this:
exec(open("C:\\Users\\user\\AppData\\Local\\Programs\\file-folder\\file.exe").read())
but when I compile the code using Geany, it gives me an error saying UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 2: character maps to undefined
I get the same error message when I try to write the file path with just one \ between each folder, but it gives me the same error in the compiler. Any help on this is greatly appreciated.
Upvotes: 0
Views: 132
Reputation: 716
you can use subprocess.call
:
import subprocess
subprocess.call(["fullPath\\yourExe.exe"])
Upvotes: 2
Reputation: 1197
well you need to import os in your code if you wanna execute external files
import os
os.startfile(""C:\\Users\\user\\AppData\\Local\\Programs\\file-folder\\file.exe"")
Upvotes: 1