{"id":94275,"date":"2016-09-08T07:00:00","date_gmt":"2016-09-08T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=94275"},"modified":"2019-03-13T11:06:35","modified_gmt":"2019-03-13T18:06:35","slug":"20160908-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20160908-00\/?p=94275","title":{"rendered":"How can I change a registry key from within the debugger?"},"content":{"rendered":"<p>If you are using a debugger based on the Windows debugging engine, you can use the <a HREF=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/hardware\/ff562389(v=vs.85).aspx\">!dreg<\/a> command to dump a registry key, but what if you want to modify a registry key? <\/p>\n<p>I don&#8217;t know how often it happens to you, but it happens to us a lot here inside Microsoft: You are given a remote debugging connection to a process that is running on some computer to which you have no physical access. You therefore cannot just run <code>regedit<\/code> and do your registry work there. You may also be in a situation where you don&#8217;t want to run <code>regedit<\/code> because running another process would interfere with the issue you are debugging.&sup1; <\/p>\n<p>One way to set a registry key from inside the debugger is to <a HREF=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/\">simulate a call to the <code>Reg&shy;Set&shy;Value&shy;Ex<\/code> function<\/a>. <\/p>\n<p>Or you can think outside the box: Use the <code>.shell<\/code> command and shell out to <code>reg.exe<\/code>. <\/p>\n<pre>\n0:001&gt; .shell reg add hkcu\\Software\\Contoso \/v UseWarpCore \/t REG_DWORD \/d 1\n<\/pre>\n<p>This assumes that the debugger was created without the <code>-noshell<\/code> option. Otherwise, you&#8217;re back to simulating the call. <\/p>\n<p>&sup1; Usually because you are debugging some focus-related problem, and running <code>regedit<\/code> changes focus. Or, if you work in my building, because you are debugging Explorer itself and therefore cannot launch any new programs. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>There&#8217;s the hard way and the easy way.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-94275","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>There&#8217;s the hard way and the easy way.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/94275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=94275"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/94275\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=94275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=94275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=94275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}