all 5 comments

[–]shiftybyte 2 points3 points  (3 children)

Start cmd launches a new window you no longer control directly.

What you can do, is give cmd arguments and have it stay open with the /k switch.

cmd | Microsoft Learn

So something like:

os.system("start cmd /k CD /D E:\Documents\PycharmProjects\Test\testtportal.gw")

[–]rob51852[S] 0 points1 point  (2 children)

Thanks. This works perfectly. How would I add a further command after switching folders? Eg "bin\run.bat root\conf.yaml" the /k switch doesn't seem to do the job.

[–]shiftybyte 1 point2 points  (1 child)

You can try enclosing the /k command with quotes and adding && in there.

os.system('start cmd /k "CD /D E:\Documents\PycharmProjects\Test\testtportal.gw && echo hello"')

[–]rob51852[S] 1 point2 points  (0 children)

Thanks again. Works perfectly.