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

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

问题描述


EDIT

如果您想在计算机启动时执行任何任务或基于
事件这是非常有帮助的

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-certain / 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).

例如


$ 这是一个批处理文件,它将用户转到某个指定的文件夹,然后等待用户从命令提示符处重命名/ b $ b

我该如何做?

How can I do it?

推荐答案

如果你想要一个定义的命令集,启动命令提示符,最佳实现方法是在自动运行中指定初始化脚本>注册表值。像这样创建它(可扩展字符串值允许您使用%USERPROFILE%)的环境变量:

If you want a defined set of commands to run every time you start a command prompt, the best way to achieve that would be to specify an init script in the AutoRun registry value. Create it like this (an expandable string value allows you to use environment variables like %USERPROFILE%):

reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun ^
  /t REG_EXPAND_SZ /d "%"USERPROFILE"%\init.cmd" /f

然后创建一个文件 init.cmd 您的个人资料文件夹:

Then create a file init.cmd in your profile folder:

@echo off

command_A
command_B
...
cls

这篇关于如何在Windows中的命令提示符启动时运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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