{"id":67803,"date":"2006-03-08T17:38:00","date_gmt":"2006-03-08T17:38:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2006\/03\/08\/how-can-i-configure-the-screensaver-used-when-no-one-is-logged-on-to-a-computer\/"},"modified":"2006-03-08T17:38:00","modified_gmt":"2006-03-08T17:38:00","slug":"how-can-i-configure-the-screensaver-used-when-no-one-is-logged-on-to-a-computer","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-configure-the-screensaver-used-when-no-one-is-logged-on-to-a-computer\/","title":{"rendered":"How Can I Configure the Screensaver Used When No One is Logged On to a Computer?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" height=\"34\" alt=\"Hey, Scripting Guy! Question\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" align=\"left\" border=\"0\"> \n<P>Hey, Scripting Guy! I recently downloaded your Script Center screensaver, and it works great as long as someone is logged on to the computer. However, when no one is logged on the computer uses a different screensaver. How can I get the computer to use the Script Center screensaver when no one is logged on?<BR><BR>&#8212; RF<\/P><IMG height=\"5\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" border=\"0\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" height=\"34\" alt=\"Hey, Scripting Guy! Answer\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" align=\"left\" border=\"0\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" height=\"288\" alt=\"Script Center\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" align=\"right\" border=\"0\"><\/A> \n<P>Hey, RF. You know, it occurred to us that you might be trying to pull a fast one on the old Scripting Guys. For example, how do we know it\u2019s really <A href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/funzone\/games\/default.mspx\"><B><I>our<\/I><\/B><B> screensaver<\/B><\/A> that you want to run when no one is logged on to the computer? Maybe this is just a way to flatter the Scripting Guys into answering your question, and then, once we do so, you\u2019ll go out and install some <I>other<\/I> scripting-related screensaver as the default. RF, RF: did you really believe that the Scripting Guys are so shallow that we\u2019d succumb to cheap flattery like that?<\/P>\n<P>Well you should have, because we are:<\/P><PRE class=\"codeSample\">Const HKEY_USERS = &amp;H80000003<\/p>\n<p>strComputer = &#8220;.&#8221;<\/p>\n<p>Set objReg = GetObject(&#8220;winmgmts:\\\\&#8221; &amp; strComputer &amp; &#8220;\\root\\default:StdRegProv&#8221;)<\/p>\n<p>strKeyPath = &#8220;.Default\\Control Panel\\Desktop&#8221;\nValueName = &#8220;SCRNSAVE.EXE&#8221;\nstrValue = &#8220;C:\\WINDOWS\\System32\\Script Center.scr&#8221;<\/p>\n<p>objReg.SetStringValue HKEY_USERS, strKeyPath, ValueName, strValue\n<\/PRE>\n<P>As you can see, this is a WMI script for changing the registry. It\u2019s very similar to the many other registry-modifying scripts we\u2019ve shown you in the past, albeit with one unique twist. In our previous scripts we\u2019ve always started out by defining a constant that tells that script that we want to work with either the HKEY_CURRENT_USER or the HKEY_LOCAL_MACHINE registry hive. And there\u2019s good reason for that: we want whatever modification we\u2019re making to apply to the current user or to the computer itself. Ah, but notice the first line of <I>this<\/I> script:<\/P><PRE class=\"codeSample\">Const HKEY_USERS = &amp;H80000003\n<\/PRE>\n<P>That\u2019s the secret right there: this time we want to work with the HKEY_USERS registry hive. Among other things, the HKEY_USERS hive provides you with a place to configure settings that, in lieu of any specific user, apply to anyone who logs on to the computer. In other words, if you configure a screensaver in HKEY_USERS, that screensaver is the default that will apply to any new user who logs on to the computer. (And that\u2019s the screensaver that will continue to apply unless the user specifically configures a different screensaver.) Likewise, when no one is logged on to the computer that\u2019s the screensaver that will be used.<\/P>\n<P>Cool, huh? Incidentally, this is also where you can configure the wallpaper that appears at the logon screen; just set the registry value HKEY_USERS\\.Default\\Control Panel\\Desktop\\Wallpaper to the appropriate file path. Something like this:<\/P><PRE class=\"codeSample\">Const HKEY_USERS = &amp;H80000003<\/p>\n<p>strComputer = &#8220;.&#8221;<\/p>\n<p>Set objReg = GetObject(&#8220;winmgmts:\\\\&#8221; &amp; strComputer &amp; &#8220;\\root\\default:StdRegProv&#8221;)<\/p>\n<p>strKeyPath = &#8220;.Default\\Control Panel\\Desktop&#8221;\nValueName = &#8220;Wallpaper&#8221;\nstrValue = &#8220;C:\\WINDOWS\\System32\\Script Center.bmp&#8221;<\/p>\n<p>objReg.SetStringValue HKEY_USERS, strKeyPath, ValueName, strValue\n<\/PRE>\n<P>After defining our constant we next connect to the WMI service on the local computer (although this script works equally well against remote computers). We then assign values to three different variables:<\/P>\n<TABLE class=\"\" cellSpacing=\"0\" cellPadding=\"0\" border=\"0\">\n<TBODY>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><B>strKeyPath<\/B> &#8211; The path to the registry key within HKEY_USERS. In this case, that\u2019s .Default\\Control Panel\\Desktop.<\/P><\/TD><\/TR>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><B>ValueName<\/B> &#8211; The name of the registry value we want to change (SCRNSAVE.EXE).<\/P><\/TD><\/TR>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><B>strValue<\/B> &#8211; The new value to be assigned to SCRNSAVE.EXE. In this script, that\u2019s the full path to the screensaver.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<P>All that\u2019s left to do now is call the <B>SetStringValue<\/B> method (passing along the constant HKEY_USERS and our three variables as parameters) and we\u2019re done:<\/P><PRE class=\"codeSample\">objReg.SetStringValue HKEY_USERS, strKeyPath, ValueName, strValue\n<\/PRE>\n<P>If you log off and wait a few minutes the Script Center screensaver should kick in. (Well, assuming that the registry value <B>ScreenSaveActive<\/B> is set to 1; if it\u2019s set to 0, that means the screensaver has been disabled.)<\/P>\n<P>See how easy that is? And no, we don\u2019t mean the script (although that\u2019s pretty easy, too); we mean how easy it is to get your question answered, provided you word that question in the right way, of course. Like they say, flattery will get you <I>anywhere<\/I>.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! I recently downloaded your Script Center screensaver, and it works great as long as someone is logged on to the computer. However, when no one is logged on the computer uses a different screensaver. How can I get the computer to use the Script Center screensaver when no one is logged on?&#8212; [&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":[16,47,31,26,3,5],"class_list":["post-67803","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-desktop-management","tag-general-management-tasks","tag-operating-system","tag-registry","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! I recently downloaded your Script Center screensaver, and it works great as long as someone is logged on to the computer. However, when no one is logged on the computer uses a different screensaver. How can I get the computer to use the Script Center screensaver when no one is logged on?&#8212; [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/67803","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=67803"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/67803\/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=67803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=67803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=67803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}