I'm trying to open the Windows command prompt using Python and then execute a few commands. This is the code I am using:
import os
os.system("start /B start cmd.exe @cmd /k cd C:/ & color 04")
Now the command prompt opens and the directory changes to just C:\> but the second command to change the color of the text doesn't work and no errors are produced. When I run cd C:/ & color 04 in the command prompt itself, it works though. So it seems my problem lies with the & sign in cd C:/ & color 4 since the command after the & does not execute.
How can I get this feature to work via my Python code (keep in mind I want the command prompt to be visible to the user)?
os.system("date & date")work or not?os.system("date & date")more minimal thanos.system("start /B start cmd.exe @cmd /k cd C:/ & color 04"). the desired behavior in former case is much more obvious