Python Forum
Open windows cmd prompt and run cmds with python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Open windows cmd prompt and run cmds with python
#1
Hello,

I'm trying to run cmds with python.

For example: I want my python program to be able to open/run MagicMirror by cd into it's directory(C:\MagicMirror) and running "node serveronly".

I tried to do this but it would run my desired cmd in the terminal running my python program. Therefore, it never ran/kept crashing.

I had this:
os.system('cmd /k "cd.. & cd.. & cd MagicMirror & node server only"')
My python program is located in a folder in my Downloads: "C:\Users\My-PC\Downloads\VoiceAssistant"
And the reason I cd.. twice is because when I manually open the cmd prompt I am in "C:\Users\My-PC" so I figured in order to get to "C:/" I cd.. twice.

But when I try running the code I end up here "C:\Users\My-PC\Downloads"

So, how do I cd into MagicMirror and run "node serveronly" using python?

I don't know if this makes sense, but any help would be greatly appreciated.

Thanks in advance.
Reply


Messages In This Thread
Open windows cmd prompt and run cmds with python - by Extra - Jul-12-2022, 10:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  'pip' not recogmnized in windows prompt MaartenRo 1 507 Dec-21-2023, 09:05 AM
Last Post: menator01
  [SOLVED] [Windows] Right way to prompt for directory? Winfried 4 2,188 Jan-17-2023, 09:28 PM
Last Post: markoberk
  Windows install does not create .exe, shortcut,etc to open hammer 4 2,141 May-05-2022, 12:33 PM
Last Post: hammer
  Is it possible to open windows and do screenshots with Python? cubangt 2 1,435 Jan-14-2022, 03:57 PM
Last Post: cubangt
  Running Python in Command Prompt Anwar 3 3,249 Nov-15-2020, 03:15 PM
Last Post: snippsat
  starting python from windows command prompt MaartenRo 4 2,970 Sep-04-2020, 12:25 PM
Last Post: MaartenRo
  Open windows media player minimised TamP 1 2,344 Aug-02-2020, 08:40 PM
Last Post: Larz60+
  Python's id() function output in prompt and script mode stormshadow 4 3,935 Dec-10-2018, 10:08 AM
Last Post: stormshadow
  Subprocess command prompt (Windows) arnaur 6 10,648 Sep-06-2018, 07:22 AM
Last Post: arnaur
  Problem with interactive python prompt Groot_04 4 3,260 Aug-02-2018, 08:39 AM
Last Post: Groot_04

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020