{"id":6858,"date":"2021-11-21T13:37:45","date_gmt":"2021-11-21T13:37:45","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=6858"},"modified":"2021-11-21T13:38:46","modified_gmt":"2021-11-21T13:38:46","slug":"batch-to-edit-delete-an-ip-from-hosts-file","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/batch-to-editdelete-an-ip-from-hosts-file\/24358.html","title":{"rendered":"Batch To Edit\/Delete An IP From Hosts File."},"content":{"rendered":"<p>Hi &#8212;<\/p>\n<p>I&#8217;m in need of some assistance in creating a batch file that will edit\/delete an IP out of the Host file.<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nI just started learning on how to create batch files so try and give a small explanation on your help please&#8230;<br \/>\nHere&#8217;s what I have so far.<\/p>\n<p>@echo off<\/p>\n<p>echo 1 is for Denver<\/p>\n<p>echo 2 is for Los Angeles<\/p>\n<p>set input=<br \/>\nset \/p input=enter your option &#8211;<\/p>\n<p>if %input%==1 goto 1<br \/>\nif %input%==2 goto 2<\/p>\n<p>:1<br \/>\necho 192.168.X.XX test.test.com&gt;&gt;c:\\Windows\\System32\\drivers\\etc\\hosts<br \/>\necho Host file has been set to point to Denver.<br \/>\npause<\/p>\n<p>:2<br \/>\necho Host file has been set to point to Los Angeles.<br \/>\npause<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>As you can see&#8230;<br \/>\n-I have it set to where prompt asks you where you want your host file pointing.<br \/>\n-When the user selects 1, it updates the Hosts file with the IP address wanted.<\/p>\n<p>Now, I want option 2 to remove that IP address, that way it reverts the Hosts file back to normal.<\/p>\n<p>Any help is appreciated.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":16},"question-category":[55],"question_tags":[],"class_list":["post-6858","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/6858","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=6858"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=6858"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=6858"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=6858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}