如何使用窗口标题启动PowerShell?

Ani*_*esh 6 powershell cmd

我有一个批处理文件,允许我根据我的输入转到特定文件夹.

d:
cd d:\test\bits
@ECHO off
cls
:start
ECHO.
ECHO 1. Perl
ECHO 2. Python
set choice=
set /p choice=type in number to go to appropriate code folder:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto pl
if '%choice%'=='2' goto py
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:pl
cd code\pl
goto end
:py
cd code\py
goto end
:end
start "bits"
Run Code Online (Sandbox Code Playgroud)

在执行结束时,将打开一个标题为"bits"的命令提示符窗口,该窗口位于与输入选项对应的指定目录中.这一切都很好.但我希望与Powershell做同样的事情.

如果,而不是start "bits",我放在start powershell最后一行,我可以打开Powershell控制台.通过这样做,我有两个问题.

  1. Powershell控制台仍在d:\test\bits文件夹中,而不是我想要的那个.
  2. 我不能得到冠军 bits

如何使用Powershell获得我想要的功能?

man*_*lds 11

根据我的预期以及我能够使用您的脚本重现的内容,当前目录设置为预期目录(d:\test\bits\code\pl如果我输入1)

对于标题部分,您可以执行以下操作:

start powershell -NoExit -command "$Host.UI.RawUI.WindowTitle = 'bits'"
Run Code Online (Sandbox Code Playgroud)