如何通过特定路径从cmd启动PowerShell

Mar*_*slo 17 windows windows-7 powershell command-line

我想从Windows 7默认命令行 ( cmd )启动PowerShell (C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe ) 并转到特定路径。

我使用了命令:

start C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe
Run Code Online (Sandbox Code Playgroud)

它会工作,并显示powershell窗口。

但是,如果我使用:

start C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe Set-Location c:\
Run Code Online (Sandbox Code Playgroud)

黑色窗口将快速闪烁。

如何通过特定路径从cmd打开powershell?提前致谢。

Der*_*ler 17

尝试这个:

powershell -NoExit -Command "Set-Location c:\\"
Run Code Online (Sandbox Code Playgroud)

如果您的路径包含空格,您可以将其用单引号括起来,如下所示:

powershell -NoExit -Command "Set-Location 'c:\\program files'"
Run Code Online (Sandbox Code Playgroud)