windows cmd 默认为 F: 驱动器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
cmd defaults to F: drive
提问by minty
When I open cmd on my laptop it is defaulting to the F: drive. This is troubling me does anyone know how it got that way or how to get it back to where it opens to the C: drive by default?
当我在笔记本电脑上打开 cmd 时,它默认为 F: 驱动器。这让我很困扰,有谁知道它是如何得到的,或者如何将它恢复到默认打开 C: 驱动器的位置?
采纳答案by OwenP
I believe it defaults to %HOMEDRIVE%\%HOMEPATH%
so if you can muck about with those environment variables that might be an option. I can't edit these environment variables on my company's network, so I had to use the AutoRunto change it to something sane.
我相信它默认为%HOMEDRIVE%\%HOMEPATH%
如此,如果您可以考虑那些可能是一个选项的环境变量。我无法在我公司的网络上编辑这些环境变量,因此我不得不使用AutoRun将其更改为正常的内容。
回答by Breath Iguana
Use the command
使用命令
C:
To change to the drive C. It would of course work for any drive letter.
更改为驱动器 C。它当然适用于任何驱动器号。
回答by Dan Haynes
Very minor nit: if you're using Windows 7 you don't need the cmdhere powertoy, it's built in to Explorer.
非常小的问题:如果您使用的是 Windows 7,则不需要 cmdhere powertoy,它内置于资源管理器中。
You just navigate to a directory in Windows Explorer then hold down the shift key and right click. "Open command window here" is one of the selections on the context menu.
您只需导航到 Windows 资源管理器中的目录,然后按住 shift 键并右键单击即可。“在此处打开命令窗口”是上下文菜单上的选项之一。
When it comes to opening cmd.exe in a specific directory, I just create a shortcut to cmd.exe and then in the shortcut properties I set "Start in:" to the drive/directory I want it to start in.
在特定目录中打开 cmd.exe 时,我只需创建一个指向 cmd.exe 的快捷方式,然后在快捷方式属性中将“开始于:”设置为我希望它开始的驱动器/目录。
Using a shortcut allows me to customize the cmd.exe windows depending on what I'm using it for. For normal file editing/viewing I use a 180x60 window and appropriate font, but when I want to read/search log files I have a shortcut that opens a 260x100 window with a smaller font. That way I can view most long log file lines without having to use the horizontal scroll.
使用快捷方式允许我根据我使用它的目的自定义 cmd.exe 窗口。对于普通的文件编辑/查看,我使用 180x60 窗口和适当的字体,但是当我想阅读/搜索日志文件时,我有一个快捷方式可以打开一个 260x100 的窗口,字体较小。这样我就可以查看最长的日志文件行而无需使用水平滚动。
回答by ceejayoz
http://blog.stevienova.com/2007/04/08/change-your-default-cmd-prompt-path/
http://blog.stevienova.com/2007/04/08/change-your-default-cmd-prompt-path/
Sometimes, your path when you go to start->run, CMD will be something you don't want. In active directory or on an NT domain, sometimes your default home path might be a network drive. This isn't so good when you are offline or drop offline after being online. The CMD prompt is set to a place where you can't get to.
To change the path, you can edit the registry (at your own risk)
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USERSoftwareMicrosoftCommand Processor] “Autorun”=”c:”
This will change the path to your c: drive.
有时,当你开始->运行时,你的路径,CMD 将是你不想要的东西。在活动目录或 NT 域中,有时您的默认主路径可能是网络驱动器。当您离线或在线后掉线时,这不是很好。CMD 提示设置到你无法到达的地方。
要更改路径,您可以编辑注册表(风险自担)
Windows 注册表编辑器 5.00 版
[HKEY_CURRENT_USERSoftwareMicrosoftCommand Processor] “Autorun”=”c:”
这将更改您的 c: 驱动器的路径。
回答by gdupuis
In RegEdit.exe I created a String:
在 RegEdit.exe 我创建了一个字符串:
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
The value I used for AutoRun was "D:"
我用于 AutoRun 的值是“D:”
回答by DrFloyd5
quick answer: cmd /k c:
快速回答: cmd /kc:
long answer to make it "automagical": http://windowsxp.mvps.org/autoruncmd.htm
使其“自动”的长答案:http: //windowsxp.mvps.org/autoruncmd.htm
回答by EBGreen
If you are opening it from a shortcut change the working dir for the shortcut.
如果您从快捷方式打开它,请更改快捷方式的工作目录。
回答by Neil Neyman
In addition to the other answers, there's a nice powertoy for XP called "open command window here." It adds an option to your right-click context menu when you click inside a folder to open a command window using that directory as the starting path.
除了其他答案之外,XP 还有一个不错的 powertoy,称为“在此处打开命令窗口”。当您在文件夹内单击以打开使用该目录作为起始路径的命令窗口时,它会向您的右键单击上下文菜单添加一个选项。
http://www.microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx
http://www.microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx
回答by tsellon
I ran into a similar issue where cmd would always open up in a particular directory (annoying when running scripts which invoke cmd). The best way to deal with this is to edit your autorun settings. Raymond Chen has a nice article about this here: http://blogs.msdn.com/oldnewthing/archive/2007/11/21/6447771.aspx
我遇到了一个类似的问题,其中 cmd 总是在特定目录中打开(在运行调用 cmd 的脚本时很烦人)。解决此问题的最佳方法是编辑您的自动运行设置。Raymond Chen 在这里有一篇很好的文章:http: //blogs.msdn.com/oldnewthing/archive/2007/11/21/6447771.aspx
The summary is that when you start a command shell, it checks the autorun registry key, and executes the commands stored there. The registry keys it checks are:
总而言之,当您启动命令外壳程序时,它会检查自动运行注册表项,并执行存储在那里的命令。它检查的注册表项是:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
回答by akcasoy
- On the start screen / menu, type in "cmd", right-click it and select "Open File - Location".
- In the opened window, right-Click on "Command Prompt" icon, select "Properties", and edit the "Start In" property to your desired path. I used "C:\" as an example
- 在开始屏幕/菜单上,输入“cmd”,右键单击它并选择“打开文件 - 位置”。
- 在打开的窗口中,右键单击“命令提示符”图标,选择“属性”,然后将“开始于”属性编辑为所需的路径。我以“C:\”为例