{"id":42,"date":"2011-02-21T16:00:01","date_gmt":"2011-02-21T23:00:01","guid":{"rendered":"http:\/\/blog.gptnet.net\/?p=42"},"modified":"2012-12-27T08:00:16","modified_gmt":"2012-12-27T15:00:16","slug":"42","status":"publish","type":"post","link":"https:\/\/blog.gptnet.net\/?p=42","title":{"rendered":".bat script registry query and change"},"content":{"rendered":"<p>The following script demonstrates how to query registry to check if specific registry key exists. If it does, it checks the value and if doesn&#8217;t match required it will remove and recreate with proper value.<br \/>\n<!--more--><br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<pre lang=\"DOS\" line=\"1\">@echo OFF\r\nREM Checks if registry key exists -> If Exists and not equals \r\nREM to something -> change to something\r\nREM Created: Dec 08, 2009\r\nREM Author: Naz Snidanko\r\n\r\nsetlocal ENABLEEXTENSIONS\r\nset KEY_NAME=\"HKEY_USERS\\.DEFAULT\\Control Panel\\International\"\r\nset VALUE_NAME=\"sShortDate\"\r\nset SerVal=M\/d\/yyyy\r\n\r\nREG QUERY %KEY_NAME% \/v %VALUE_NAME%\r\n\r\nif %errorlevel% EQU 0 goto Rexist\r\nif %errorlevel% EQU 1 goto NotExist1\r\n\r\n:NotExist1\r\necho Its not here!\r\ngoto :DoNe\r\n\r\n:Rexist\r\necho Its Here!\r\n\r\nFOR \/F \"usebackq skip=4 tokens=1-3\" %%A IN (`REG QUERY %KEY_NAME% \/v %VALUE_NAME% 2^>nul`) DO (\r\n\r\n    set ValueName=%%A    \r\n    set ValueType=%%B   \r\n    set ValueValue=%%C\r\n)\r\n\r\nIF %ValueValue% NEQ %SerVal% GOTO Change\r\n\r\ngoto DoNe\r\n\r\n:Change\r\nREG DELETE %KEY_NAME% \/v %VALUE_NAME% \/f\r\nREG ADD %KEY_NAME% \/v %VALUE_NAME% \/t REG_SZ \/d %SerVal% \/f\r\ngoto DoNe\r\n:doNe\r\n<\/pre>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nHope it helps!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following script demonstrates how to query registry to check if specific registry key exists. If it does, it checks the value and if doesn&#8217;t match required it will remove and recreate with proper value.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,1],"tags":[8,9,11],"class_list":["post-42","post","type-post","status-publish","format-standard","hentry","category-bat","category-random-stuff","tag-bat-2","tag-bat-script","tag-registry-query"],"_links":{"self":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=42"}],"version-history":[{"count":10,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts\/42\/revisions"}],"predecessor-version":[{"id":130,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts\/42\/revisions\/130"}],"wp:attachment":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}