Open Command Prompt with specific directory using Python
Asked Answered
Q

1

5

How can I open command prompt with specific directory using Python?

I could just run command prompt using Python but I'm unable to open with specific directory.

import os
os.system("start cmd")
Qktp answered 1/8, 2019 at 10:45 Comment(1)
cmd can take arguments (run cmd /? to see them) you can do cmd /K cd c:/ to start cmd at c:Retroact
B
7

You can open the specific path using this

import os
os.system("start cmd /K cd C:\\Users\\Name\\Desktop\\File" )
Bs answered 1/8, 2019 at 10:54 Comment(6)
Great thanks a lot. Now I have to execute the below command using python. Could you please help with the flow py <filename> –V <variant string> -p <path to the flash files>Qktp
@SujiRyali What exactly are you trying to achieve? Are you trying to get the version of python?Bs
no I have to flash the component. For which I am opening command prompt with specific directory using python. and then execute flashing command next an extension to opening CMD py <filename> –V <variant string> -p <path>Qktp
@SujiRyali You can change your working directory to the desired path and then input the call. I have answered your other question.Bs
If I would like to open the command prompt in the directory where I run the python script that opens the command prompt is. How could I write the syntax after cd...?Centralization
This only works so long as you are starting within drive C:Mow

© 2022 - 2024 — McMap. All rights reserved.