如何在 Windows 中的命令提示符启动时运行命令 [英] How to run a command on command prompt startup in Windows
问题描述
编辑
如果您想在计算机启动时或基于这个活动很有帮助
If you want to perform any task at computer startup or based on an event this is very helpful
<小时>
回到问题
我有两个问题:
我希望在启动命令提示符时执行一些特定的命令.
I want some specific commands to be executed when I start command prompt.
例如cls
清除我的命令提示符.
e.g. cls
to clear my command prompt.
我想在批处理文件中执行一些命令并等待用户输入新命令(如果有).
I want to execute some commands in a batch file and wait for the user to enter new commands (if any).
例如一个批处理文件,它将把用户带到某个指定的文件夹,然后等待用户从命令提示符重命名/删除文件.
e.g. A batch file which will take the user to some specified folder and then wait for the user to rename/delete a file from the command prompt.
我该怎么做?
推荐答案
我找到了答案:我应该使用 /K
开关,使用它我可以在打开的命令提示符下输入新命令.
I found my answer: I should use the /K
switch, using which I can enter a new command on the opened command prompt.
例如cmd/K cls
将为我打开一个命令提示符并清除它.(问题 1 的答案)
E.g. cmd /K cls
will open a command prompt for me and clear it. (Answer for question 1)
和
cmd/K MyBatchFile.bat
将启动命令提示符,执行批处理文件并停留在命令提示符处,不会退出.(回答问题 2).
cmd /K MyBatchFile.bat
will start a command prompt, execute the batch file and stay on the command prompt and will not exit. (Answer for question 2).
这篇关于如何在 Windows 中的命令提示符启动时运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!