Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables 如何在批处理中使用变量更改目录?_Variables_Batch File_Cd - Fatal编程技术网

Variables 如何在批处理中使用变量更改目录?

Variables 如何在批处理中使用变量更改目录?,variables,batch-file,cd,Variables,Batch File,Cd,我试图使用一个变量来更改批处理文件中的当前目录。 变量设置为Dan,并且有一个名为Dan的文件夹。但这并没有改变。这是我的密码 cd C:\Users\%username%\AppData\Roaming\PBot\Profiles set /p profilename=Enter your profile name: cd %profilename% 使用cd/D更改驱动器号和路径。键入cd/?以获得更详细的解释。您的问题问得很好,但研究得不充分。谢谢,韦斯。但我已经试过了,从我读到的内容来

我试图使用一个变量来更改批处理文件中的当前目录。 变量设置为Dan,并且有一个名为Dan的文件夹。但这并没有改变。这是我的密码

cd C:\Users\%username%\AppData\Roaming\PBot\Profiles
set /p profilename=Enter your profile name:
cd %profilename%

使用
cd/D
更改驱动器号和路径。键入
cd/?
以获得更详细的解释。您的问题问得很好,但研究得不充分。谢谢,韦斯。但我已经试过了,从我读到的内容来看,cd/d是用来更换驱动器的。我可能错了,但这对我来说不起作用。把所有的路径名和路径变量都用引号引起来是一种很好的做法。另外,您可以尝试%userprofile%变量
cd“%userprofile%\AppData\Roaming\PBot\Profiles”
cd“%profilename%”
。它可以更改为Profiles文件夹,而不是Dan文件夹。