Change directory in batch file with PowerShell

I need to changed directory using batch file in PowerShell.

Let's say the batch file named go.bat has the two lines of code. And I'm in q: directory.

   c:
   cd c:\abc\def

When I run go.bat, I'm still in q:


While I agree that what you're doing should work, you can always try the Powershell cmdlet "set-location". It basically works the same way:

set-location c:\abc\def

When you run a batch file, PowerShell creates a CMD.EXE process to run the file. If you change the working directory inside the CMD.EXE process, it won't affect the current working directory of PowerShell. This is by design.