{"id":250,"date":"2012-05-14T09:55:20","date_gmt":"2012-05-14T07:55:20","guid":{"rendered":"https:\/\/www.npcglib.org\/~stathis\/blog\/?p=250"},"modified":"2013-10-01T05:48:52","modified_gmt":"2013-10-01T03:48:52","slug":"windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder","status":"publish","type":"post","link":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/","title":{"rendered":"windows task: Open Visual C++ command prompt by right-clicking a folder"},"content":{"rendered":"<p>[Update: I devised <a href=\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/12\/28\/windows-task-create-command-prompts-for-visual-studio-2008-2010-and-2012-all-in-one\/\" title=\"windows task: create command prompts for Visual Studio 2008, 2010 and 2012 (all-in-one)\">an improved method to create command prompts for Visual Studio 2008, 2010 and 2012 all-in-one.<\/a>]<\/p>\n<p>I open a command prompt so often that it has become a burden to have to use a stock cmd shortcut and cd to the right directory. It is easy to add an option to the context menu that comes up when you right click a directory on Windows Explorer. I have been experimenting with various methods to easily do this. Here is two of them.<\/p>\n<h2>First Method<\/h2>\n<p>This uses environment variables from your system to find the necessary VC files necessary. I prefer this method, because the context menu option does not require that you know where Visual Studio 2010 and VS are installed. It is also trivial in that you just execute it from a cmd window and you&#8217;re ready to go. I provide here two batch files that you can execute on your system (<u>of course at your own risk!!<\/u>) to set this up right away:<\/p>\n<ul>\n<li><a href=\"\/~stathis\/downloads\/vs2010-x86-cmd-prompt.bat\">vs2010-x86-cmd-prompt.bat<\/a> &#8211; Batch file for VS2010 x86 Prompt Context Menu<\/li>\n<li><a href=\"\/~stathis\/downloads\/vs2010-x64-cmd-prompt.bat\">vs2010-x64-cmd-prompt.bat<\/a> &#8211; Batch file for VS2010 x64 Prompt Context Menu<\/li>\n<\/ul>\n<p>Below is a brief explanation of what the individual steps in the batch files do. (<strong><u>Do not run these from a command prompt, use a batch file, like those provided above. You are not supposed to run the commands below on a command prompt as variable expansion will mess things up!!<\/u><\/strong>)<\/p>\n<p>For 32-bit, we first create the context menu entry, which is what you see on the menu, by executing:<\/p>\n<pre>\r\nreg add HKEY_CLASSES_ROOT\\Directory\\shell\\VS2010cmd-x86 \/ve \/f \/d \"VS2010 x86 Prompt\"\r\n<\/pre>\n<p>Then for the command to be executed when you click on that menu entry, we execute (in one line):<\/p>\n<pre>\r\nreg add HKEY_CLASSES_ROOT\\Directory\\shell\\VS2010cmd-x86\\command \r\n        \/ve \/t REG_EXPAND_SZ \/f \/d \"%%comspec%% \/V:ON \/K \r\n        \"\"\"\"\"\"%%VS100COMNTOOLS%%VCVarsQueryRegistry.bat\"\"\"\"\"\" 32bit ^&amp;^&amp; \r\n        ^!VCINSTALLDIR^!vcvarsall.bat x86 ^&amp;^&amp; cd \/d %%1\"\r\n<\/pre>\n<p>Respectively for the 64-bit VS2010 cross compiler tools prompt, first create the context menu entry by executing:<\/p>\n<pre>\r\nreg add HKEY_CLASSES_ROOT\\Directory\\shell\\VS2010cmd-x64 \/ve \/f \/d \"VS2010 x64 Prompt\"\r\n<\/pre>\n<p>Then for the command to be executed when you right-click on that entry, execute (in one line):<\/p>\n<pre>\r\nreg add HKEY_CLASSES_ROOT\\Directory\\shell\\VS2010cmd-x64\\command\r\n        \/ve \/t REG_EXPAND_SZ \/f \/d \"%%comspec%% \/V:ON \/K\r\n        \"\"\"\"\"\"%%VS100COMNTOOLS%%VCVarsQueryRegistry.bat\"\"\"\"\"\" 64bit ^&amp;^&amp;\r\n        ^!VCINSTALLDIR^!vcvarsall.bat x86_amd64 ^&amp;^&amp; cd \/d %%1\"\r\n<\/pre>\n<p>One can easily set this up for other versions of Microsoft Visual Studio. For example, you can exchange the VS100COMNTOOLS variable with VS90COMNTOOLS for a prompt to work with Visual Studio 2008.<\/p>\n<hr \/>\n<h2>Second Method<\/h2>\n<p>Another, less versatile method is to do the following. This has the limitation that it uses fixed paths, while the first one will work on any system. However with this method you have more control of what happens and you are not bound to use a batch script.<\/p>\n<p>Open the Registry Editor (regedit.exe) add a registry key under:<\/p>\n<pre>HKEY_CLASSES_ROOT\\Directory\\shell<\/pre>\n<p>Name it anything (I named mine <code>CommandPrompt<\/code>) and give it a data value, for example <code>VS2010 Command Prompt<\/code>, this is the text that will appear in the context menu. Create a new key under this newly create <code>CommandPrompt<\/code> key and name it <code>command<\/code>. The value of this key should use vcvarsall.bat of your Visual Studio installation in order for the environment to be set properly when you open the cmd window. The following value for that key does it for my installation:<\/p>\n<pre>cmd \/k \"\"D:\\dev\\msvc2010\\VC\\vcvarsall.bat\"\" x86 &amp;&amp; cd \/d %1<\/pre>\n<p>replace <code>D:\\dev\\msvc2010<\/code> with the installation path of your visual studio and you&#8217;re done. To find out the right path to the vcvarsall.bat file you can look at the shortcut created by your VS installer. You can also replace <code>x86<\/code> (for instance with ia64, amd64, x86_amd64, x86_ia64) to request that another environment is setup if you are cross-compiling for instance.<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/vs_prompt_context_menu.png\"><img loading=\"lazy\" class=\"aligncenter  wp-image-275\" title=\"Creating a context menu entry to open the Visual Studio 2010 cmd prompt.\" src=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/vs_prompt_context_menu.png\" alt=\"\" width=\"777\" height=\"213\" srcset=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/vs_prompt_context_menu.png 863w, https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/vs_prompt_context_menu-300x82.png 300w\" sizes=\"(max-width: 777px) 100vw, 777px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Update: I devised an improved method to create command prompts for Visual Studio 2008, 2010 and 2012 all-in-one.] I open a command prompt so often that it has become a burden to have to use a stock cmd shortcut and cd to the right directory. It is easy to add an option to the context [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[9,17,16],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"stathis\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#website\",\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/\",\"name\":\"sigmoid\",\"description\":\"..oo..oo..oo..oo..oo..oo..\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/vs_prompt_context_menu.png\",\"contentUrl\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/vs_prompt_context_menu.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/#webpage\",\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/\",\"name\":\"windows task: Open Visual C++ command prompt by right-clicking a folder - sigmoid\",\"isPartOf\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/#primaryimage\"},\"datePublished\":\"2012-05-14T07:55:20+00:00\",\"dateModified\":\"2013-10-01T03:48:52+00:00\",\"author\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"windows task: Open Visual C++ command prompt by right-clicking a folder\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41\",\"name\":\"stathis\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g\",\"caption\":\"stathis\"},\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/author\/stathis\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/","twitter_misc":{"Written by":"stathis","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#website","url":"https:\/\/www.npcglib.org\/~stathis\/blog\/","name":"sigmoid","description":"..oo..oo..oo..oo..oo..oo..","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.npcglib.org\/~stathis\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/#primaryimage","inLanguage":"en-US","url":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/vs_prompt_context_menu.png","contentUrl":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/vs_prompt_context_menu.png"},{"@type":"WebPage","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/#webpage","url":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/","name":"windows task: Open Visual C++ command prompt by right-clicking a folder - sigmoid","isPartOf":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/#primaryimage"},"datePublished":"2012-05-14T07:55:20+00:00","dateModified":"2013-10-01T03:48:52+00:00","author":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41"},"breadcrumb":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/14\/windows-task-open-visual-c-command-prompt-by-right-clicking-a-folder\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.npcglib.org\/~stathis\/blog\/"},{"@type":"ListItem","position":2,"name":"windows task: Open Visual C++ command prompt by right-clicking a folder"}]},{"@type":"Person","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41","name":"stathis","image":{"@type":"ImageObject","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#personlogo","inLanguage":"en-US","url":"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g","caption":"stathis"},"url":"https:\/\/www.npcglib.org\/~stathis\/blog\/author\/stathis\/"}]}},"_links":{"self":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/250"}],"collection":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/comments?post=250"}],"version-history":[{"count":20,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/250\/revisions"}],"predecessor-version":[{"id":1210,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/250\/revisions\/1210"}],"wp:attachment":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/media?parent=250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/categories?post=250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/tags?post=250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}