简体   繁体   中英

How to run an “.exe” file from “C:\Program Files (x86)” using python?

Context: Basically I want to create a python program that asks me what Software I want to run, as soon as I start my computer.

Usefull code: os.chdir(r'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe') . And that's the error I got :

FileNotFoundError Traceback (most recent call last) in () ----> 1 os.chdir(r"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'")

FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden: "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'"

The translation for "Das System kann die angegebene Datei nicht finden:" is the system was unable to find the file.

Problem: My problem is that I can't run any ".exe", or any type of files, because of the white spaces in "C:\\Program Files (x86) " , so my question would be how can I bypass that? / What could I use to make it work?

PS: I searched, on various forums, but this problem doesn't seem to be very common... Or I didn't search enough.

使用os.system()或提供一个文件夹路径来更改os.chdir()目录, os.chdir()不是更改可执行文件(为什么要更改为可执行文件?您不能这样做)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM