I want to launch a external program like notepad.exe using python. I want to have a script that just runs Notepad.exe.
Asked
Active
Viewed 920 times
1
-
1Take a look at the `subprocess` module. – brunns Apr 26 '19 at 13:33
3 Answers
1
It's really simple with Python's builtin os
module.
This will start Microsoft Notepad:
import os
# can be called without the filepath, because notepad is added to your PATH
os.system('notepad.exe')
Or if you want to launch any other program just use:
import os
# r for raw-string, so don't have to escape backslashes
os.system(r'path\to\program\here\program.exe')

ruohola
- 21,987
- 6
- 62
- 97
0
Would recommend the subprocess
module. Just build up a list of arguments like you would run in the terminal or command line if you are on windows then run it.
import subprocess
args = ['path\to\program\here\program.exe']
subprocess.call(args)
Check out the docs here for all of the other process management functionality.

Jello
- 420
- 6
- 13
-1
this can be done using Python OS. Please see the code below for an example.
import os
os.startfile('test.txt')
Startfile will execute the program associated with the file extension.

Joseph P Nardone
- 150
- 2
- 12
-
This could start any text editor and not just Notepad, depending on the file extension associations. – ruohola Apr 26 '19 at 13:36
-
Yes correct, not sure why you downvoted when I say that in my response. – Joseph P Nardone Apr 26 '19 at 13:37
-
-
-
3Maybe the downvote was for not answering the question. Question: "How can I start a specific external program". Answer: "Take a file and hope that the correct program is started" – Matthias Apr 26 '19 at 13:40
-
The reason why I suggested using this, is because it generates the file in one step, rather than having to execute additional commands to generate your text file after opening notepad. – Joseph P Nardone Apr 26 '19 at 13:40