{"id":71743,"date":"2004-08-02T19:12:00","date_gmt":"2004-08-02T19:12:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2004\/08\/02\/registry-script-doesnt-work\/"},"modified":"2004-08-02T19:12:00","modified_gmt":"2004-08-02T19:12:00","slug":"registry-script-doesnt-work","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/registry-script-doesnt-work\/","title":{"rendered":"Registry Script Doesn&#039;t Work"},"content":{"rendered":"<p><img decoding=\"async\" class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"><\/p>\n<p>Hey, Scripting Guy! I tried writing a script to read data from the registry, but I keep getting this error:<\/p>\n<div><img decoding=\"async\" border=\"0\" alt=\"Error Screenshot\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/heyht1.jpg\" width=\"396\" height=\"173\"><\/div>\n<p>&nbsp;<\/p>\n<p>Do you have any idea what&#8217;s wrong? I&#8217;m running Windows XP Professional, Service Pack 1, and this is the code I&#8217;m using:<\/p>\n<pre class=\"codeSample\">Const HKEY_LOCAL_MACHINE = &amp;H80000002\nstrComputer = \".\"\nSet oReg=GetObject(\"winmgmts:\\\\\" &amp;_\n    strComputer &amp; \"\\root\\cimV2:StdRegProv\")\nstrKeyPath = \"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon\"\nstrValueName = \"UIHost\"\noReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath,_\nstrValueName,strValue\nWscript.Echo \"The Windows logon UI host is: \" &amp; strValue\n<\/pre>\n<p>&#8212; LW, Omaha, NE<\/p>\n<p><img decoding=\"async\" border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><img decoding=\"async\" class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><a href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><img decoding=\"async\" class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/a><\/p>\n<p>Hey, LW. The error you are getting (80041010) means that the specified class (in this case, root\\cimv2:StdRegProv) is invalid; in other words, there&#8217;s no such class. How could that be? Well, believe it or not, there&#8217;s a simple reason for this: there really <i>is<\/i> no such class as root\\cimv2:stdRegProv. Instead, the standard registry provider (stdRegprov) is actually found in root\\default, <i>not<\/i>, in root\\cimv2. Change your code to look like this, and you should be fine:<\/p>\n<pre class=\"codeSample\">Set oReg=GetObject(\"winmgmts:\\\\\" &amp;_\n    strComputer &amp; \"\\root\\default:StdRegProv\")\n<\/pre>\n<p>By the way, how did we know that error number 80041010 meant that you referenced an invalid class? Easy: we just looked up the error number in the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa394582(VS.85).aspx\"><b>WMI SDK<\/b><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! I tried writing a script to read data from the registry, but I keep getting this error: &nbsp; Do you have any idea what&#8217;s wrong? I&#8217;m running Windows XP Professional, Service Pack 1, and this is the code I&#8217;m using: Const HKEY_LOCAL_MACHINE = &amp;H80000002 strComputer = &#8220;.&#8221; Set oReg=GetObject(&#8220;winmgmts:\\\\&#8221; &amp;_ strComputer &amp; [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26,3,5,6],"class_list":["post-71743","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-registry","tag-scripting-guy","tag-vbscript","tag-wmi"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! I tried writing a script to read data from the registry, but I keep getting this error: &nbsp; Do you have any idea what&#8217;s wrong? I&#8217;m running Windows XP Professional, Service Pack 1, and this is the code I&#8217;m using: Const HKEY_LOCAL_MACHINE = &amp;H80000002 strComputer = &#8220;.&#8221; Set oReg=GetObject(&#8220;winmgmts:\\\\&#8221; &amp;_ strComputer &amp; [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/71743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=71743"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/71743\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=71743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=71743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=71743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}