如何通过命令提示符更改标题并保留系统信息

时间:2018-02-20 06:41:44

标签: c windows

我正在尝试通过命令行启动一个进程,但是当我使用/k选项 cmd 时,我会丢失所有系统信息。如何保留此信息,是否有可能更改标题的环境变量。

//first line where I sprintf commands into a buffer
sprintf(commandLine_buf,"%s  /T:F9 /K TITLE=What is your command ",getenv("ComSpec"))

@erksun感谢你的建议。我修改了一下但是有效。这就是它的样子。以下

sprintf(commandLine_buf, "cmd /c PROMPT Speak to me$G & TITLE What is your command? & \"%s\"",getenv("ComSpec"));

我的提示如下:

enter image description here

但我希望它看起来像这样:

enter image description here

1 个答案:

答案 0 :(得分:0)

在最后的实现中,我在另一行上获得了ComSpec值并运行了sprintf函数,如下所示:

char* ComSpecVar;
ComSpecVar = getenv("ComSpec");
sprintf(commandLine_buf, "cmd /c COLOR F9 & PROMPT Speak to me$G & "
    "TITLE What is your command? & \"%s\"", ComSpecVar);

后续提示如下所示:

enter image description here