windows 如何在批处理文件中更改为当前用户的目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7159941/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:42:18  来源:igfitidea点击:

How to Change to current user's directory in a batch file

windowsbatch-filecmd

提问by Michael Skelton

How is it possible to change to a user default directory

如何更改为用户默认目录

Is there a default variable that can be used e.g. %USER%

是否有可以使用的默认变量,例如 %USER%

would return: C:\Users\MyUsername

将返回:C:\Users\MyUsername

回答by Oded

Use %HOMEPATH%.

使用%HOMEPATH%.

So:

所以:

CD %HOMEPATH%