简体   繁体   English

在命令提示符启动时运行命令

[英]Run command on Command Prompt start

有没有一种方法可以在命令提示符启动时运行任何命令(例如:cd D:\\ test),并将此命令提示符实例作为不同的快捷方式/实例。

You can create a shortcut that has a target of eg: 您可以创建一个目标为例如的快捷方式:

%comspec% /k ""C:\Full_Path_to\VsDevCmd.bat""

Where the .bat file is the command(s) that you want to run on startup. .bat文件是您要在启动时运行的命令。 This will then leave you with an open command prompt after those commands have executed. 执行完这些命令后,这将为您提供一个打开的命令提示符。

(In case it's not obvious, this is just shamelessly ripped from one of the Developer Command Prompt shortcuts that Visual Studio installs in the Start Menu) (以防万一,这只是从Visual Studio在“开始”菜单中安装的“开发人员命令提示符”快捷方式之一中偷偷摸摸地摘下来的)


%comspec% is a nice way of getting cmd to execute. %comspec%是一种使cmd执行的好方法。

Cmd : Cmd

/k : Carries out the command specified by string and continues. / k :执行字符串指定的命令并继续。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM