0

why cant i run this program ?

import os os.system("notepad.exe") ------------------------------------------------------- 'Notepad' is not recognized as an internal or external command, operable program or batch file.

26th Oct 2024, 12:20 PM
ali
5 Answers
+ 3
ali , on an up-to-date windows environment there are some restrictions (by default) to run code like this (executing applications) in vscode. ensure you have permission to run applications like notepad, as some environments restrict program execution. you could modity the settings for this behaviour, but it is not recommended since harmful `exe` files could create security issues.
26th Oct 2024, 3:53 PM
Lothar
Lothar - avatar
+ 2
You are trying to run NOTEPAD.EXE. The error message is telling you this is not a valid command. Are you running this python script on your Windows PC? If not, then that's the problem. Notepad.exe does not exist on a Mac, on a phone, or in the SoloLearn Code editor. It only exists in Microsoft Windows.
26th Oct 2024, 1:53 PM
Jerry Hobby
Jerry Hobby - avatar
+ 2
If you are running this script on Windows, it should work. The only reason I can think of that it does not work is if Notepad is not in your path. But notepad should be in your path, so that's interesting. If you go to a CMD shell prompt, type NOTEPAD, does that work? Can you try to run other commands? The key issue here is the error message. It is saying notepad is not found. I've tested your code on my machine and it works fine. Try this: import os os.system("echo 'Hello World!'") You should see "Hello World!" in your console.
26th Oct 2024, 3:29 PM
Jerry Hobby
Jerry Hobby - avatar
+ 1
its on windows
26th Oct 2024, 1:59 PM
ali
+ 1
I made a test on Windows, and it is working. notepad.exe is located in the Windows folder, so first, you better check if notepad.exe is existing in your Windows folder. If it exists, which it normally does, then you could try enter the full path in the Python script like... "C:\\Windows\\notepad.exe"
26th Oct 2024, 5:02 PM
Jan
Jan - avatar