powershell windows-7 shortcuts

Abrir Powershell en un directorio específico de acceso directo



windows-7 shortcuts (7)

Copie este código en el bloc de notas y guárdelo con una extensión reg. Haga doble clic en el archivo resultante. Si recibe un mensaje sobre la importación al registro, haga clic en Sí y luego en Aceptar. Navega a cualquier carpeta en el explorador y abre el menú contextual. Esto generalmente se hace haciendo clic con el botón derecho del mouse.

Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT/Directory/Background/shell/PShell] "MUIVerb"="Open in Powershell Window" [HKEY_CLASSES_ROOT/Directory/Background/shell/PShell/command] @="c://windows//system32//WindowsPowerShell//v1.0//powershell.exe -NoExit -Command Set-Location -LiteralPath ''%V''"

Esto suena como debería ser tan simple ... Debo ser tonto.

Todo lo que quiero es hacer un atajo de Windows que abre Powershell en un directorio específico:

Estoy usando el objetivo:

%SystemRoot%/system32/WindowsPowerShell/v1.0/powershell.exe -noexit -command {cd c:/path/to/open}

Ponlo simplemente escupe el comando como texto.


Ok, necesitas usar el parámetro & para especificar que es un comando powershell y la sintaxis es ligeramente diferente:

%SystemRoot%/system32/WindowsPowerShell/v1.0/powershell.exe -noexit -command "& {cd c:/path/to/open}"


Si desea que PowerShell comience como administrador y se ejecute en un directorio específico, incluso en un disco diferente, es mejor usar el comando Set-Location . Sigue estos pasos

  1. Cree un ShortCutLink con el objetivo siendo el exe powershellcommand.
  2. Leave Start in: blanco. ( Normalmente esto comienza en el directorio de trabajo actual cuando está en blanco, pero no nos importa ) .
  3. Cambie el Target a esto con sus objetivos para powershell y ubicaciones:

    C:/Windows/.../v1.0/powershell.exe -noexit -command "Set-Location D:/_DCode/Main"

  4. Haga clic en Advanced... y seleccione Run as administrator .
  5. Haga clic en OK s out.

No olvides el útil truco para cambiar los colores del atajo de la pestaña Colors . De esta forma, si tienes dos o más enlaces que abren ventanas de PowerShell, ver un color diferente puede hacerte ver visualmente en qué shell está trabajando.


También puede establecer el campo de acceso directo "Iniciar en" en la ubicación deseada.


o use: powershell.exe -noexit -command "cd c:/temp "


tratar:

%SystemRoot%/system32/WindowsPowerShell/v1.0/powershell.exe -noexit -command "cd c:/path/to/open"


New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT if(-not (Test-Path -Path "HKCR:/Directory/shell/$KeyName")) { Try { New-Item -itemType String "HKCR:/Directory/shell/$KeyName" -value "Open PowerShell in this Folder" -ErrorAction Stop New-Item -itemType String "HKCR:/Directory/shell/$KeyName/command" -value "$env:SystemRoot/system32/WindowsPowerShell/v1.0/powershell.exe -noexit -command Set-Location ''%V''" -ErrorAction Stop Write-Host "Successfully!" } Catch { Write-Error $_.Exception.Message } } else { Write-Warning "The specified key name already exists. Type another name and try again." }

Puede descargar el script detallado de cómo iniciar PowerShell desde Windows Explorer