Multiple ways to open PowerShell in the current Explorer window

Posted on October 14, 2008. Filed under: explorer, powershell, right click, user interface, vista, windows |

These techniques are generic and can be used for other items like command prompt as well. A word of caution, everything given below involves fiddling with the registry so please backup your system’s registry or create a restore point before trying this out.

1) Adding it to Vista Explorer’s toolbar:

image

This is the most convenient one in my opinion, but requires most work to enable it.

Firstly, navigate to the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\FolderTypes\{7d49d726-3c21-4f05-99aa-fdc2c9474656}

Its should have the following items:

image

Note that it has following two items:

  1. TasksItemsSelected: Enabled when an item is selected in the view.
  2. TasksNoItemsSelected: Enabled when nothing is selected in the view.

Each of these keys have multiple items inside them each pointing to separate shortcut inside the toolbar.

Import the following registry file so that the PowerShell icon appears in the toolbar:

Download From Skydrive

Before importing I will also point out that I am assuming the a batch file exists at the following path:

C:\\Users\\Gaurav\\Programs\\shortcuts\\psh_launch.bat %2

The content of this file should be:

   1: @echo off
   2: pushd %1
   3: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
   4: @echo

You can search and replace the location of this file to your custom location inside the just downloaded registry file. Its being used in two places.

Also, remember to take a backup of this registry key or make a restore point before importing this registry key.

That’s it. Now a PowerShell Icon should appear inside the every folder.

 

The PowerShell icon still doesn’t appear?

Actually the registry file only modifies the folders of Document Type and the PowerShell icon will appear only inside folders of Document Type.

An easy way to make all the folders inside a Drive Document Type:

right click on drive/partition –> select Properties –> select Customize tab-> and select following options:

image 

So this way we just forced all the folders in the drive to be of Document Type.

The same procedure can be used to add multiple items on the toolbar. Its a lot of work but the end result is worth it 🙂

 

2) Using AutoHotKey

AutoHotKey is used for creating keyboard macros.

AutoHotKey will use the same batch file that was created to launch PowerShell in the current directory.

Here is the script:

   1: !p::
   2: IfWinActive ahk_class CabinetWClass
   3: {
   4: WinGetClass explorerClass, A
   5: ControlGetText currentPath, Edit1, ahk_class %explorerClass%
   6: run C:\\Users\\Gaurav\\Programs\\shortcuts\\psh_launch.bat "%currentPath%"
   7: }
   8: return

Just fix path to the batch file, save and reload AutoHotKey.

Now press Alt + P to launch PowerShell inside the current explorer window.

 

3) Right Click Menu

image

To add PowerShell to right click menu navigate to following registry entry:

HKEY_CLASSES_ROOT\Directory\Background\shell

and create a key with name powershell inside shell and a key with name command inside it. Edit the default value of command key to:

C:\Users\Gaurav\Programs\shortcuts\psh_launch.bat “%V”

This is same batch file created earlier and the exact path needs to be fixed.

or just import this file into your registry and fix the path to the batch file:

Download from Skydrive

That’s it, now PowerShell should show up in you right-click menu inside any directory.

Advertisements

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

2 Responses to “Multiple ways to open PowerShell in the current Explorer window”

RSS Feed for Blogging on Technology Comments RSS Feed

Awesome!

This reminds me of the time when you and me used to write the ruby+dos scripting and play with the registries to do the similar stuffs for getting the Rails server, bp and console in context menus.
🙂

@Sur: Yeah, that was a lot of fun 🙂


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: