打开命令提示符窗口,改变当前工作目录 [英] open command prompt window and change current working directory
问题描述
我非常新的脚本在Windows上。使用Windows 7 64。
I'm terribly new to scripting on windows. Using windows 7 64.
我试图做一个.bat文件,我可以双击,并将其打开命令提示符窗口,并自动 CD
我某个目录。
I'm trying to make a .bat file that I can double click, and have it open a command prompt and automatically cd
me to a certain directory.
我试图使以
@ECHO OFF
cmd "cd C:\my\destination"
这将打开看起来像一个命令提示符,但似乎并没有让我输入的任何命令。
Which opens what looks like a command prompt, but doesn't seem to let me type any commands.
我然后设法:
@ECHO OFF
start cmd "cd C:\my\destination"
但是,这只是给我发成一个圈打开提示吨,吨,直到我的电脑坏了:) .bat文件位于目标目录如果该事项。
But this just sent me into a loop opening tons and tons of prompts until my computer crashed :) The .bat file was located in the destination directory if that matters.
推荐答案
这对我的作品:
@ECHO OFF
cmd.exe /K "cd C:\my\destination && C:"
加引号的字串实际上是两个指令(用双符号隔开):第一个命令是改变到指定目录,第二个命令切换到指定的驱动器盘符
The quoted string is actually two commands (separated by a double ampersand): The first command is to change to the specified directory, the second command is to change to the specified drive letter.
将这个批处理文件(.bat),当你执行它,你应该在指定的目录中看到一个命令提示符窗口。
Put this in a batch (.BAT) file and when you execute it you should see a Command Prompt window at the specified directory.
这篇关于打开命令提示符窗口,改变当前工作目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!