用于在特定目录中启动powershell的批处理文件

Poo*_*oja 3 windows powershell batch

我正在通过《Learn python the Hard way》一书学习Python编程。因此我使用 powershell 来运行我的程序。由于每次启动 powershell 时都必须手动更改目录,因此我编写了一个批处理文件来自动化它。

我写的命令是:

powershell.exe -noexit -command "'cd c:\self\pooja\"edu n career"\programs\python'"
Run Code Online (Sandbox Code Playgroud)

问题是它运行但仅打开“程序”目录。为什么它没有更改为 python 目录?

最后,我通过在 powershell 的快捷方式属性中设置“开始于”字段来完成此操作,但我想知道为什么批处理文件没有按预期工作。

Knu*_*ger 5

关闭 Nate,但是当我在“新文件夹”上运行它时,这不起作用。必须将 CD 移到单引号之外才能使其正常工作。

powershell.exe -noexit -command "cd 'c:\New folder'"
powershell.exe -noexit -command "cd 'c:\self\pooja\edu n career\programs\python'"
Run Code Online (Sandbox Code Playgroud)