Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

How start PowerShell from cmd by specific path

Writer Andrew Henderson

I want to start PowerShell (C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe) from windows 7 default command line (cmd) and go to the specific path.

I used the command:

start C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe

It'll work, and show the powershell window.

But, if I use:

start C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe Set-Location c:\

The black window will flash quickly.

How can I open powershell from cmd by the specific path? Thanks in advance.

2

2 Answers

Try this:

powershell -NoExit -Command "Set-Location c:\\"

If your path contains spaces, you can wrap it in single-quotes, like so:

powershell -NoExit -Command "Set-Location 'c:\\program files'"
5

What Windows 10 uses in the Registry in order to open a PowerShell instance by shift-rightclicking in an Explorer window or on the Desktop ("Open PowerShell window here") is the following:

powershell.exe -noexit -command Set-Location -literalPath '%V'

This can be found at Computer\HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell\command

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy