Reputation: 651
My target is to show the Windows command prompt and display a command on the command line without executing it. Therefore, if I want to display the command echo Hello
, I want the command prompt to be started and display:
C:\Windows\System32>echo Hello_
... where _ is the blinking cursor waiting for the user to press a key.
To accomplish this, I've tried either to create a shortcut to the Windows command prompt executable, that has its "Target" changed to:
C:\Windows\System32\cmd.exe ...
or a bat file containing:
cmd.exe /k ...
... where /k stands for:
/k : Carries out the command specified by string and continues
This makes the command prompt continue to live and not terminate the way the /c switch acts.
Any idea how to achieve this result?
Upvotes: 1
Views: 3022
Reputation: 200483
You can't achieve what you want with cmd
alone. It could be done with a VBScript, though.
Set sh = CreateObject("WScript.Shell")
sh.Run "%COMSPEC% /k @title MyCmd"
sh.AppActivate "MyCmd"
sh.SendKeys "echo Hello"
Upvotes: 2
Reputation: 2279
I had test and the result success. But dont know is this what you search..
set /p id=hello
Is that what you wish?
Upvotes: 1