Windows – How to open a batch file and execute a command AFTER opening command prompt

batchcommand linewindows

I am trying to create a batch file that first opens command prompt and then executes "prompt $t$gEnter Command Here$g". I have tried starting it with "%windir%\system32\cmd.exe" and then using "&&" to run the "prompt $t$gEnter Command Here$g" afterwards but I cannot get it to work. My reason for doing this is to have command prompt open through the batch file and display "prompt $t$gEnter Command Here$g" as the return. So it would say "{Time}> Enter Command Here>" for each return. Please help.

Best Answer

The Start verb will open cmd in a new window. This works for me in a .bat:

start cmd /K PROMPT $t$gEnter Command Here$g

the /K will keep the cmd window open after running the prompt command, so you can use the shell.

Just save it in a batch file, and invoke by double-click or in another command window.

Related Question