Windows Vista Forums

Power Tool - Start PowerShell from Here
  1. #1


    Fred Jacobowitz Guest

    Power Tool - Start PowerShell from Here

    This is a wish list item. The power toys for XP have start command line
    here. How about start powershell here?
    Fred Jacobowitz





      My System SpecsSystem Spec

  2. #2


    =?Utf-8?B?ZHJlZXNjaGtpbmQ=?= Guest

    RE: Power Tool - Start PowerShell from Here

    Put the following inside a plain text file and name it powershell.reg and
    install it.
    You will need to adjust the PowerShell path according to your install
    directory of PowerShell.
    ##############################################
    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\shell\PowerShell]
    @="PoSh Prompt Here"

    [HKEY_CLASSES_ROOT\Directory\shell\PowerShell\command]
    @="C:\\Programme\\Windows PowerShell\\v1.0\\powershell.exe -Noexit -Nologo
    -Command Set-Location '%L'"
    ##############################################

    --
    greetings
    dreeschkind


    "Fred Jacobowitz" wrote:

    > This is a wish list item. The power toys for XP have start command line
    > here. How about start powershell here?
    > Fred Jacobowitz
    >
    >
    >


      My System SpecsSystem Spec

  3. #3


    =?Utf-8?B?Um9tYW4gS3V6bWlu?= Guest

    RE: Power Tool - Start PowerShell from Here

    Correction for unistall:

    Uninstall-PowerShellHere.reg:
    ---8<---
    REGEDIT4
    [-HKEY_CLASSES_ROOT\Directory\shell\PowerShell Here]
    ---8<---

    --
    Thanks,
    Roman


      My System SpecsSystem Spec

  4. #4


    =?Utf-8?B?Um9tYW4gS3V6bWlu?= Guest

    RE: Power Tool - Start PowerShell from Here

    You can do it yourself. Assume that powershell.exe is here: "C:\Program
    Files\Windows PowerShell\v1.0\powershell.exe". Create and use the following
    ..reg files.

    Install-PowerShellHere.reg:
    ---8<---
    REGEDIT4
    [HKEY_CLASSES_ROOT\Directory\shell\PowerShell Here\command]
    @="C:\\Program Files\\Windows PowerShell\\v1.0\\powershell.exe"
    ---8<---

    Uninstall-PowerShellHere.reg:
    ---8<---
    REGEDIT4
    [-HKEY_CLASSES_ROOT\Directory\shell\PowerShell Here\command]
    ---8<---

    After applying of 'Install-PowerShellHere.reg' Explorer folder context menu
    has the item 'PowerShell Here'.

    Note: this solution works fine always but for a folder in Explorer folder
    tree ('left panel'). If you run 'PowerShell Here' for a folder in the 'right
    panel' then PowerShell starts in the parent folder but not in the selected
    one. If you do not like it you can use this

    Install-PowerShellHere.reg:
    ---8<---
    REGEDIT4
    [HKEY_CLASSES_ROOT\Directory\shell\PowerShell Here\command]
    @="C:\\Program Files\\Windows PowerShell\\v1.0\\powershell.exe -noexit cd
    '%1'"
    ---8<---

    but this (simple) solution will not work for folder paths containing
    `,',[,]. To fix this funny issue you may try more complicated command
    replacing `,' with ``, `' and [,] with ``[,``]. (LOL, how trivial everyday
    tasks may be difficult in PS...). I would compose it but I really hope that
    it will be incompatible with coming PS versions.

    --
    Thanks,
    Roman


      My System SpecsSystem Spec

  5. #5


    Fred Jacobowitz Guest

    Re: Power Tool - Start PowerShell from Here

    dreeschkind,
    Perfect - Thank you! Where do I find command line options for PowerShell?
    Thank you,
    Fred Jacobowitz

    "dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message
    news:8D5A4A9D-9FA3-446B-86E5-D1B42904A5E0@microsoft.com...
    > Put the following inside a plain text file and name it powershell.reg and
    > install it.
    > You will need to adjust the PowerShell path according to your install
    > directory of PowerShell.
    > ##############################################
    > Windows Registry Editor Version 5.00
    >
    > [HKEY_CLASSES_ROOT\Directory\shell\PowerShell]
    > @="PoSh Prompt Here"
    >
    > [HKEY_CLASSES_ROOT\Directory\shell\PowerShell\command]
    > @="C:\\Programme\\Windows PowerShell\\v1.0\\powershell.exe -Noexit -Nologo
    > -Command Set-Location '%L'"
    > ##############################################
    >
    > --
    > greetings
    > dreeschkind
    >
    >
    > "Fred Jacobowitz" wrote:
    >
    >> This is a wish list item. The power toys for XP have start command line
    >> here. How about start powershell here?
    >> Fred Jacobowitz
    >>
    >>
    >>




      My System SpecsSystem Spec

  6. #6


    Alex K. Angelopoulos [MVP] Guest

    Re: Power Tool - Start PowerShell from Here

    I played with the commandline you showed for setting the current directory,
    and have a couple of modifications that may make it better. If you make the
    command tail into this:

    -NoExit -Command [Environment]::CurrentDirectory =
    (Set-Location -Path:'%L' -PassThru)

    it gives a couple of advantages. The [Environment]::CurrentDirectory ensures
    that working directory is also set to the PS location. The %L forces long
    name treatment, and by joining it to the -Path parameter name explicitly, it
    appears that almost all weird substitutions are suppressed. In fact, the
    only odd characters that I had trouble with were [] due to attempts at
    wildcard expansion. The following bizarre folder on my desktop worked fine
    as a target:

    New, Folder`with P{}weird )_( chars in !~Name()

    "Roman Kuzmin" <RomanKuzmin@discussions.microsoft.com> wrote in message
    news:6CFBBD61-CF49-4733-9216-8B3FE45EF3F7@microsoft.com...
    > You can do it yourself. Assume that powershell.exe is here: "C:\Program
    > Files\Windows PowerShell\v1.0\powershell.exe". Create and use the
    > following
    > .reg files.
    >
    > Install-PowerShellHere.reg:
    > ---8<---
    > REGEDIT4
    > [HKEY_CLASSES_ROOT\Directory\shell\PowerShell Here\command]
    > @="C:\\Program Files\\Windows PowerShell\\v1.0\\powershell.exe"
    > ---8<---
    >
    > Uninstall-PowerShellHere.reg:
    > ---8<---
    > REGEDIT4
    > [-HKEY_CLASSES_ROOT\Directory\shell\PowerShell Here\command]
    > ---8<---
    >
    > After applying of 'Install-PowerShellHere.reg' Explorer folder context
    > menu
    > has the item 'PowerShell Here'.
    >
    > Note: this solution works fine always but for a folder in Explorer folder
    > tree ('left panel'). If you run 'PowerShell Here' for a folder in the
    > 'right
    > panel' then PowerShell starts in the parent folder but not in the selected
    > one. If you do not like it you can use this
    >
    > Install-PowerShellHere.reg:
    > ---8<---
    > REGEDIT4
    > [HKEY_CLASSES_ROOT\Directory\shell\PowerShell Here\command]
    > @="C:\\Program Files\\Windows PowerShell\\v1.0\\powershell.exe -noexit cd
    > '%1'"
    > ---8<---
    >
    > but this (simple) solution will not work for folder paths containing
    > `,',[,]. To fix this funny issue you may try more complicated command
    > replacing `,' with ``, `' and [,] with ``[,``]. (LOL, how trivial everyday
    > tasks may be difficult in PS...). I would compose it but I really hope
    > that
    > it will be incompatible with coming PS versions.
    >
    > --
    > Thanks,
    > Roman
    >




      My System SpecsSystem Spec

  7. #7


    =?Utf-8?B?ZHJlZXNjaGtpbmQ=?= Guest

    Re: Power Tool - Start PowerShell from Here

    "Fred Jacobowitz" wrote:

    > dreeschkind,
    > Perfect - Thank you! Where do I find command line options for PowerShell?


    Start PowerShell.exe with the parameter "-?" from cmd.exe or PowerShell
    itself.

    C:\>powershell -?

    powershell.exe [-PSConsoleFile cf] [-Help] [-NoLogo] [-NoExit] [-NoProfile]
    [-OutputFormat of] [-NonInteractive]
    [-Command] string [remainingArgs]
    powershell.exe [-PSConsoleFile cf] [-Help] [-NoLogo] [-NoExit] [-NoProfile]
    [-OutputFormat of] [-InputFormat if] [-NonInteractive]
    [-Command] script-block [-args arg-array]
    powershell.exe [-Version v] [-Help] [-NoLogo] [-NoExit] [-NoProfile]
    [-OutputFormat of] [-NonInteractive]
    [-Command] string [remainingArgs]
    powershell.exe [-Version v] [-Help] [-NoLogo] [-NoExit] [-NoProfile]
    [-OutputFormat of] [-InputFormat if] [-NonInteractive]
    [-Command] script-block [-args arg-array]

    -PSConsoleFile
    Load the Windows(R) PowerShell console file at startup.
    -Version
    Start a particular version of Windows(R) PowerShell.
    -Help, -?, /?
    Show this message.
    -NoLogo
    Skip writing the copyright banner on startup.
    -NoExit
    Don't exit after running all startup commands.
    -NoProfile
    Skip execution of user initialization script.
    -OutputFormat
    How the shell formats output data.
    Value can be "Text" (text strings) or "XML" (serialized CLIXML format).
    -InputFormat
    How the system will format data piped to the shell.
    Value can be "Text" (text strings) or "XML" (serialized CLIXML format).
    -Noninteractive
    Never present an interactive prompt to the user.
    -Command
    Execute the remaining command-line parameters as though they were typed
    at the Windows(R) PowerShell command prompt. Then exit, unless -NoExit
    is s
    pecified.
    The value can be specified as a string or a script block. A script block
    can only be specified when the user is currently running a Windows(R)
    PowerS
    hell.
    - If a string, -Command must be the last option specified, as it uses
    all remaining parameters specified as its own arguments.
    If '-' is specified as the command, then the command text is read from
    standard input.
    - If a script block (enclosed in { } brackets), then data to/from the
    shell
    will automatically be serialized from/to the pipeline in the parent
    shell.

    Arguments are specified as a single array following the -args parameter.


    --
    greetings
    dreeschkind


    > Thank you,
    > Fred Jacobowitz
    >
    > "dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message
    > news:8D5A4A9D-9FA3-446B-86E5-D1B42904A5E0@microsoft.com...
    > > Put the following inside a plain text file and name it powershell.reg and
    > > install it.
    > > You will need to adjust the PowerShell path according to your install
    > > directory of PowerShell.
    > > ##############################################
    > > Windows Registry Editor Version 5.00
    > >
    > > [HKEY_CLASSES_ROOT\Directory\shell\PowerShell]
    > > @="PoSh Prompt Here"
    > >
    > > [HKEY_CLASSES_ROOT\Directory\shell\PowerShell\command]
    > > @="C:\\Programme\\Windows PowerShell\\v1.0\\powershell.exe -Noexit -Nologo
    > > -Command Set-Location '%L'"
    > > ##############################################
    > >
    > > --
    > > greetings
    > > dreeschkind
    > >
    > >
    > > "Fred Jacobowitz" wrote:
    > >
    > >> This is a wish list item. The power toys for XP have start command line
    > >> here. How about start powershell here?
    > >> Fred Jacobowitz
    > >>
    > >>
    > >>

    >
    >
    >


      My System SpecsSystem Spec

  8. #8


    Fred Jacobowitz Guest

    Re: Power Tool - Start PowerShell from Here

    Alex,
    Nice work. One problem. I do not get the Power Shell Here command on top
    level folders: e.g.; C:. However, I get it for all the subfolders. Any
    thoughts? I do get Open Command Window here at the top level folders.
    Thank you,
    Fred Jacobowitz

    "Alex K. Angelopoulos [MVP]" <aka@online.mvps.org> wrote in message
    news:ud15crUwGHA.2120@TK2MSFTNGP03.phx.gbl...
    >I played with the commandline you showed for setting the current directory,
    >and have a couple of modifications that may make it better. If you make the
    >command tail into this:
    >
    > -NoExit -Command [Environment]::CurrentDirectory =
    > (Set-Location -Path:'%L' -PassThru)
    >
    > it gives a couple of advantages. The [Environment]::CurrentDirectory
    > ensures that working directory is also set to the PS location. The %L
    > forces long name treatment, and by joining it to the -Path parameter name
    > explicitly, it appears that almost all weird substitutions are suppressed.
    > In fact, the only odd characters that I had trouble with were [] due to
    > attempts at wildcard expansion. The following bizarre folder on my desktop
    > worked fine as a target:
    >
    > New, Folder`with P{}weird )_( chars in !~Name()
    >
    > "Roman Kuzmin" <RomanKuzmin@discussions.microsoft.com> wrote in message
    > news:6CFBBD61-CF49-4733-9216-8B3FE45EF3F7@microsoft.com...
    >> You can do it yourself. Assume that powershell.exe is here: "C:\Program
    >> Files\Windows PowerShell\v1.0\powershell.exe". Create and use the
    >> following
    >> .reg files.
    >>
    >> Install-PowerShellHere.reg:
    >> ---8<---
    >> REGEDIT4
    >> [HKEY_CLASSES_ROOT\Directory\shell\PowerShell Here\command]
    >> @="C:\\Program Files\\Windows PowerShell\\v1.0\\powershell.exe"
    >> ---8<---
    >>
    >> Uninstall-PowerShellHere.reg:
    >> ---8<---
    >> REGEDIT4
    >> [-HKEY_CLASSES_ROOT\Directory\shell\PowerShell Here\command]
    >> ---8<---
    >>
    >> After applying of 'Install-PowerShellHere.reg' Explorer folder context
    >> menu
    >> has the item 'PowerShell Here'.
    >>
    >> Note: this solution works fine always but for a folder in Explorer folder
    >> tree ('left panel'). If you run 'PowerShell Here' for a folder in the
    >> 'right
    >> panel' then PowerShell starts in the parent folder but not in the
    >> selected
    >> one. If you do not like it you can use this
    >>
    >> Install-PowerShellHere.reg:
    >> ---8<---
    >> REGEDIT4
    >> [HKEY_CLASSES_ROOT\Directory\shell\PowerShell Here\command]
    >> @="C:\\Program Files\\Windows PowerShell\\v1.0\\powershell.exe -noexit cd
    >> '%1'"
    >> ---8<---
    >>
    >> but this (simple) solution will not work for folder paths containing
    >> `,',[,]. To fix this funny issue you may try more complicated command
    >> replacing `,' with ``, `' and [,] with ``[,``]. (LOL, how trivial
    >> everyday
    >> tasks may be difficult in PS...). I would compose it but I really hope
    >> that
    >> it will be incompatible with coming PS versions.
    >>
    >> --
    >> Thanks,
    >> Roman
    >>

    >
    >




      My System SpecsSystem Spec

  9. #9


    =?Utf-8?B?Um9tYW4gS3V6bWlu?= Guest

    Re: Power Tool - Start PowerShell from Here

    "Alex K. Angelopoulos [MVP]" wrote:
    …

    Interesting remarks, thanks.

    As for

    "Alex K. Angelopoulos [MVP]" wrote:
    > In fact, the
    > only odd characters that I had trouble with were [] due to attempts at
    > wildcard expansion.


    - this is strange, I think that '(apostrophe) should be problematic too, did
    you try? So, I expect problems with path characters:

    `'[] - in RC1
    '[] - in RC2 (' must be doubled in single quoted strings)

    --
    Thanks,
    Roman


      My System SpecsSystem Spec

  10. #10


    =?Utf-8?B?ZHJlZXNjaGtpbmQ=?= Guest

    Re: Power Tool - Start PowerShell from Here

    "Alex K. Angelopoulos [MVP]" wrote:

    > it gives a couple of advantages. The [Environment]::CurrentDirectory ensures
    > that working directory is also set to the PS location. The %L forces long
    > name treatment, and by joining it to the -Path parameter name explicitly, it
    > appears that almost all weird substitutions are suppressed. In fact, the
    > only odd characters that I had trouble with were [] due to attempts at
    > wildcard expansion. The following bizarre folder on my desktop worked fine
    > as a target:
    >
    > New, Folder`with P{}weird )_( chars in !~Name()
    >


    Oh, I didn't even know that my solution doesn't always work (I don't use
    that very often and I don't have many bizarre' folders).
    I tested your solution, but I can't get it working with the example folder
    name you mentioned. Are you sure that it works? The problem seems to be the
    backtick. I get the error message the folder doesn't exist.

    Any ideas?

    PS 1: Note that $ is also an allowed character in the filesystem and should
    be tested, too.
    PS 2: I hope that all this wildcard-square-bracket-backtick problems with
    path and file names disappear someday...

    --
    greetings
    dreeschkind

      My System SpecsSystem Spec

Page 1 of 2 12 LastLast
Power Tool - Start PowerShell from Here problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Useful tool for power enthusiasts on the go (advanced power options) VaguelyRapt General Discussion 4 23 Jul 2012
Power Point - Grouping tool greyed out alex r. .NET General 3 16 Apr 2009
Help us decide what to PowerShell tool to release next. klumsy PowerShell 1 21 Dec 2008
Using old tool from the PowerShell prompt Jakob Bindslet PowerShell 1 13 Dec 2008
Wish List Powershell Tool Bar Fred J. PowerShell 5 11 Apr 2007