1

I want to launch a external program like notepad.exe using python. I want to have a script that just runs Notepad.exe.

Calvin
  • 43
  • 5

3 Answers3

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