如何在 Windows 中的命令提示符启动时运行命令 [英] How to run a command on command prompt startup in Windows

查看:19
本文介绍了如何在 Windows 中的命令提示符启动时运行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑

如果您想在计算机启动时或基于这个活动很有帮助

If you want to perform any task at computer startup or based on an event this is very helpful

http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/how-to-schedule-computer-to-shut-down-at-a-确定/800ed207-f630-480d-8c92-dff2313c193b

<小时>

回到问题

我有两个问题:

  1. 我希望在启动命令提示符时执行一些特定的命令.

  1. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆