So starten Sie PowerShell von cmd nach spezifischem Pfad

Ich möchte PowerShell starten (C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe) von Windows 7 Standard-Befehlszeile (cmd) und gehen Sie zu dem bestimmten Pfad.

Ich habe den Befehl verwendet:

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

Es funktioniert und zeigt das Powershell-Fenster an.

Aber wenn ich benutze:

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

Das schwarze Fenster blinkt schnell.

Wie kann ich Powershell von cmd aus über den bestimmten Pfad öffnen? Danke im Voraus.

Author: Marslo, 2013-04-25

2 answers

Versuche das:

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

Wenn Ihr Pfad Leerzeichen enthält, können Sie ihn wie folgt in Anführungszeichen setzen:

powershell -NoExit -Command "Set-Location 'c:\\program files'"
 16
Author: Der Hochstapler,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2013-04-26 08:38:46

Was Windows 10 in der Registrierung verwendet, um eine PowerShell-Instanz durch Umschalt-Rechtsklick in einem Explorer-Fenster oder auf dem Desktop zu öffnen ("PowerShell-Fenster hier öffnen"), ist Folgendes:

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

Dies finden Sie unter Computer\HKEY_CLASSES_ROOT\Directory\Background\shell\Powershell\command

 0
Author: Daniel F,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2019-08-11 10:06:19