Sunday, January 1, 2017

windows 7 - How start PowerShell from cmd by specific path


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.


Answer



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'"

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...