{"id":123,"date":"2008-03-26T19:23:59","date_gmt":"2008-03-26T19:23:59","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/add-edit-hosts-file-option-in-the-context-menu\/"},"modified":"2019-06-04T05:19:30","modified_gmt":"2019-06-04T05:19:30","slug":"add-edit-hosts-file-option-in-the-context-menu","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/add-edit-hosts-file-option-in-the-context-menu\/","title":{"rendered":"Add &#8220;Edit HOSTS file&#8221; option in the context menu"},"content":{"rendered":"<p>The <a title=\"Wikipedia article on Hosts file\" href=\"http:\/\/en.wikipedia.org\/wiki\/Hosts_file\" target=\"_blank\" rel=\"noopener noreferrer\">HOSTS<\/a> file, originally introduced to resolve hostnames to IP addresses, is also an effective tool to block Malware. To modify the HOSTS file in <strong>Windows<\/strong>, you need to elevate <em>Notepad.exe<\/em> or any other text editor which you use. Otherwise, you&#8217;ll see the following error when trying to save the HOSTS file:<\/p>\n<div class=\"err\">\nCannot create the C:\\Windows\\system32\\drivers\\etc\\hosts file.<\/p>\n<p>Make sure that the path and the file name are correct.\n<\/p><\/div>\n<p><!--more--><\/p>\n<p>Here is a registry edit which adds the <strong>Edit HOSTS file<\/strong> option in the (This PC) <strong>Computer<\/strong> context menu, which when clicked, runs <em>Notepad.exe<\/em> elevated and opens the HOSTS file for you. This uses the <strong>runas<\/strong> verb for elevation.<\/p>\n<h2>&#8220;Edit HOSTS File&#8221; context menu option<\/h2>\n<ul>\n<li>Download <a href=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/03\/edit-hosts-context-menu.zip\">edit-hosts-context-menu.zip<\/a> and save to Desktop<\/li>\n<li>Extract the files <strong>EditHosts.reg<\/strong> and <strong>undo.reg<\/strong> to a folder<\/li>\n<li>Double-click EditHosts.reg to apply the contents to the registry. Click <strong>Yes<\/strong> when asked for confirmation.\n<p><strong>Edit HOSTS file<\/strong> option is now in the context menu of <strong>This PC<\/strong> (Computer).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/hosts3.gif\" alt=\"\" width=\"212\" height=\"128\" border=\"0\" \/><\/li>\n<\/ul>\n<ul>\n<li>To remove <strong>Edit HOSTS file<\/strong> from the context menu, apply the <strong>undo.reg<\/strong> file.<\/li>\n<\/ul>\n<h3>Related Posts<\/h3>\n<p>We\u2019ve used the <strong>runas<\/strong> verb in the past to do the following:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.winhelponline.com\/blog\/open-elevated-command-prompt-windows\/\">Open an elevated Command Prompt from the folder context menu<\/a><\/li>\n<li><a href=\"https:\/\/www.winhelponline.com\/blog\/vbscripts-and-uac-elevation\/\">Elevate a Vbscript file using the &#8220;runas&#8221; parameter in ShellExecute<\/a><\/li>\n<li><a href=\"https:\/\/www.winhelponline.com\/blog\/register-dlls-elevated-using-the-context-menu\/\">Register DLLs (elevated) using the context menu<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The HOSTS file, originally introduced to resolve hostnames to IP addresses, is also an effective tool to block Malware. To modify the HOSTS file in Windows, you need to elevate Notepad.exe or any other text editor which you use. Otherwise, you&#8217;ll see the following error when trying to save the HOSTS file: Cannot create the &#8230; <a title=\"Add &#8220;Edit HOSTS file&#8221; option in the context menu\" class=\"read-more\" href=\"https:\/\/www.winhelponline.com\/blog\/add-edit-hosts-file-option-in-the-context-menu\/\" aria-label=\"Read more about Add &#8220;Edit HOSTS file&#8221; option in the context menu\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7],"tags":[441],"class_list":["post-123","post","type-post","status-publish","format-standard","hentry","category-windows","tag-registry"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1071,"url":"https:\/\/www.winhelponline.com\/blog\/run-program-elevated-right-click-menu-windows\/","url_meta":{"origin":123,"position":0},"title":"How to Add a Right-Click Menu Option to Run a Program Elevated","author":"Ramesh","date":"August 18, 2010","format":false,"excerpt":"From the Windows Taskbar, you can start a program elevated by holding the Ctrl & Shift keys and then clicking on a pinned shortcut. To launch a program elevated from the right-click menu, you can add custom entries and launch it using a script or using the NirCmd utility. Earlier\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"take ownership right-click menu","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/09\/take_ownership_context_menu.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":988,"url":"https:\/\/www.winhelponline.com\/blog\/process-monitor-track-events-generate-log-file\/","url_meta":{"origin":123,"position":1},"title":"Using Process Monitor to Track Registry and File System Changes","author":"Ramesh","date":"February 1, 2009","format":false,"excerpt":"Process Monitor is an excellent troubleshooting tool from Windows Sysinternals that displays the files and registry keys that applications access in real-time. The results can be saved to a log file, which you can send to an expert for analyzing a problem and troubleshooting it. This article tells you how\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"ProcMon PML log","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2009\/02\/procmon-save-log.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":213,"url":"https:\/\/www.winhelponline.com\/blog\/add-the-open-with-notepad-context-menu-option-for-all-file-types\/","url_meta":{"origin":123,"position":2},"title":"Add &#8220;Open with Notepad&#8221; to the Right-click Menu for all file types","author":"Ramesh","date":"April 24, 2008","format":false,"excerpt":"There are situations where you need to open plain-text files having an unknown or unregistered file extension using Notepad. By default, no file association exists for extension-less files and files with unknown extension in Windows. So, to open those files, you use the Open With option and select Notepad from\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"add open with notepad to right-click","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/04\/open_with_notepad.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/04\/open_with_notepad.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/04\/open_with_notepad.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":24227,"url":"https:\/\/www.winhelponline.com\/blog\/associate-file-no-extension-program\/","url_meta":{"origin":123,"position":3},"title":"How to Associate a Program with Files that have No Extension","author":"Ramesh","date":"June 18, 2021","format":false,"excerpt":"Shell extensions for file names with no file extension can be registered under the following: [HKEY_CLASSES_ROOT\\.] For example, to associate a program (for example, Notepad.exe) to open all files with no extension, use the following registry keys: [HKEY_CLASSES_ROOT\\.] @=\"\" [HKEY_CLASSES_ROOT\\.\\shell] [HKEY_CLASSES_ROOT\\.\\shell\\open] [HKEY_CLASSES_ROOT\\.\\shell\\open\\command] @=\"<path to notepad.exe> %1\" Here is an alternative\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"associate extension-less files with a program","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2021\/06\/associate-extension-less-files-2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":127,"url":"https:\/\/www.winhelponline.com\/blog\/adding-the-run-as-administrator-option-for-vbs-and-js-files\/","url_meta":{"origin":123,"position":4},"title":"Add Run as Administrator Context Menu Item for VBS and JS files","author":"Ramesh","date":"March 27, 2008","format":false,"excerpt":"By default, Windows does not include the Run as Administrator option in the context menu for Vbscript (.VBS) and JScript (.JS) files. So, to run a script elevated, you either need to launch the script from elevated Command Prompt window, or use the VBScript self-elevation method as described in article\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"add run as administrator context menu for vbs files","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/script_runas.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":5410,"url":"https:\/\/www.winhelponline.com\/blog\/run-command-elevated-administrator-ctrl-shift-enter-windows-10\/","url_meta":{"origin":123,"position":5},"title":"Start Programs Elevated (as Administrator) from Run Dialog in Windows 10 [Ctrl + Shift]","author":"Ramesh","date":"September 15, 2017","format":false,"excerpt":"If you want to edit your HOSTS file or any file that requires admin privileges to edit, you need to open Notepad or your preferred text editor as administrator.\u00a0To start a program elevated, you usually right-click on the shortcut and click Run as Administrator from the context menu. Alternately, you\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"start menu elevate program ctrl shift","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2017\/09\/run-elevated-3.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=123"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/123\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}