<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gaurav &#187; right click</title>
	<atom:link href="http://allyourcodearebelongto.me/blog/category/right-click/feed/" rel="self" type="application/rss+xml" />
	<link>http://allyourcodearebelongto.me/blog</link>
	<description>All About Everything</description>
	<lastBuildDate>Sun, 23 Nov 2008 19:44:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Multiple ways to open PowerShell in the current Explorer window</title>
		<link>http://allyourcodearebelongto.me/blog/2008/10/14/multiple-ways-to-open-powershell-in-the-current-explorer-window/</link>
		<comments>http://allyourcodearebelongto.me/blog/2008/10/14/multiple-ways-to-open-powershell-in-the-current-explorer-window/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 16:42:35 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[explorer]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[right click]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://techblogging.wordpress.com/2008/10/14/multiple-ways-to-open-powershell-in-the-current-explorer-window/</guid>
		<description><![CDATA[

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:
 
This is the most convenient one [...]]]></description>
			<content:encoded><![CDATA[</p>
</p>
<p>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.</p>
<h2>1) Adding it to Vista Explorer’s toolbar:</h2>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image11.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb12.png" width="478" height="176"></a> </p>
<p>This is the most convenient one in my opinion, but requires most work to enable it.</p>
<p>Firstly, navigate to the following registry key:</p>
<p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\FolderTypes\{7d49d726-3c21-4f05-99aa-fdc2c9474656}</p>
<p><span id="more-121"></span>
<p>Its should have the following items:</p>
<p><a href="http://techblogging.files.wordpress.com/2008/10/image12.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb13.png" width="381" height="107"></a> </p>
<p>Note that it has following two items:</p>
<ol>
<li><strong>TasksItemsSelected</strong>: Enabled when an item is selected in the view.
<li><strong>TasksNoItemsSelected</strong>: Enabled when nothing is selected in the view.</li>
</ol>
<p>Each of these keys have multiple items inside them each pointing to separate shortcut inside the toolbar.</p>
<p>Import the following registry file so that the PowerShell icon appears in the toolbar:</p>
<p><a href="http://cid-49208a72e4eb818c.skydrive.live.com/self.aspx/world/code/vista%20toolbar.reg">Download From Skydrive</a></p>
<p>Before importing I will also point out that I am assuming the a batch file exists at the following path:</p>
<p>C:\\Users\\Gaurav\\Programs\\shortcuts\\psh_launch.bat %2</p>
<p>The content of this file should be:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> @echo off</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span> pushd %1</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span> %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span> @echo</pre>
</div>
</div>
<p>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.</p>
<p>Also, remember to take a backup of this registry key or make a restore point before importing this registry key.</p>
<p>That&#8217;s it. Now a PowerShell Icon should appear inside the every folder.</p>
<p>&nbsp;</p>
</p>
<h2>The PowerShell icon still doesn’t appear?</h2>
<p>Actually the registry file only modifies the folders of <strong>Document Type</strong> and the PowerShell icon will appear only inside folders of <strong>Document Type.</strong></p>
<p>An easy way to make all the folders inside a Drive <strong>Document Type:</strong></p>
<p>right click on drive/partition –&gt; select Properties –&gt; select Customize tab-&gt; and select following options:</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image13.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb14.png" width="360" height="160"></a>&nbsp; </p>
<p>So this way we just forced all the folders in the drive to be of <strong>Document Type.</strong></p>
<p>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 :)</p>
<p>&nbsp;</p>
<h2>2) Using AutoHotKey</h2>
<p><a href="http://www.autohotkey.com/">AutoHotKey</a> is used for creating keyboard macros. </p>
<p>AutoHotKey will use the same batch file that was created to launch PowerShell in the current directory.</p>
<p>Here is the script:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> !p::</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span> IfWinActive ahk_class CabinetWClass</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span> {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span> WinGetClass explorerClass, A</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span> ControlGetText currentPath, Edit1, ahk_class %explorerClass%</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span> run C:\\Users\\Gaurav\\Programs\\shortcuts\\psh_launch.bat <span style="color:#006080;">"%currentPath%"</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span> }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span> <span style="color:#0000ff;">return</span></pre>
</div>
</div>
<p>Just fix path to the batch file, save and reload AutoHotKey.</p>
<p>Now press Alt + P to launch PowerShell inside the current explorer window.</p>
<p>&nbsp;</p>
<h2>3) Right Click Menu</h2>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image14.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb15.png" width="480" height="304"></a> </p>
<p>To add PowerShell to right click menu navigate to following registry entry:</p>
<p>HKEY_CLASSES_ROOT\Directory\Background\shell</p>
<p>and create a key with name <strong>powershell</strong> inside shell and a key with name command inside it. Edit the default value of command key to:</p>
<p>C:\Users\Gaurav\Programs\shortcuts\psh_launch.bat &#8220;%V&#8221;</p>
<p>This is same batch file created earlier and the exact path needs to be fixed.</p>
<p>or just import this file into your registry and fix the path to the batch file:</p>
<p><a href="http://cid-49208a72e4eb818c.skydrive.live.com/self.aspx/world/code/right-click-powershell.reg">Download from Skydrive</a></p>
<p>That’s it, now PowerShell should show up in you right-click menu inside any directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://allyourcodearebelongto.me/blog/2008/10/14/multiple-ways-to-open-powershell-in-the-current-explorer-window/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

