-1

I need to run the desired program in an application I am developing. I know I can run cmd commands with the code os.system in Python's built-in OS module.

But when I run the start command with cmd and try to open an application that is not on the computer, windows shows me an ugly pop-up message. To prevent this, I need to scan the files on the computer and find out if the desired program exists before running the "start" command. How can I do that?

1 Answers1

1

you can use:

os.path.exists(directory)

To check if a file exists in python. However, it is better to use:

os.path.isfile(directory)

In this case so that you wont get the error message with the path does not point to a file, but still exists.

Eli Harold
  • 2,280
  • 1
  • 3
  • 22