{"id":65953,"date":"2006-11-29T08:00:00","date_gmt":"2006-11-29T08:00:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2006\/11\/29\/how-can-i-change-the-text-for-the-marquee-screen-saver\/"},"modified":"2006-11-29T08:00:00","modified_gmt":"2006-11-29T08:00:00","slug":"how-can-i-change-the-text-for-the-marquee-screen-saver","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-change-the-text-for-the-marquee-screen-saver\/","title":{"rendered":"How Can I Change the Text for the Marquee Screen Saver?"},"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! How can I change the text for the Marquee screen saver?<\/p>\n<p>&#8212; SJ<\/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, SJ. Greetings from the frozen wasteland formerly known as Redmond, WA. On Monday night a freak November snowstorm hit the Seattle area. However, instead of leaving behind snow it left behind an inch or so of ice; ice which, in turn, has pretty much left the entire region paralyzed. (If you\u2019re from the Midwest\/Alaska\/Norway\/Greenland or anywhere else that doesn\u2019t shut down completely just because you get a little ice and snow feel free to insert your favorite \u201cPeople from Seattle are so wimpy\u201d joke here.) Is it really that bad here? Well, let\u2019s put it this way: people actually slept in their cars on the freeway last night: traffic wasn\u2019t going anywhere and they were too far from home to walk. And so they spent the night sleeping in their cars on I-405.<\/p>\n<p>Yuck.<\/p>\n<p>Things aren\u2019t much better as the Scripting Guy who writes this column writes this column Tuesday morning. Other than one person down the hall (who looks as though she might have spent the night here) the Scripting Guys\u2019 building is pretty much deserted: obviously everyone either was legitimately prevented from coming in to work due to icy roads, or they phoned in and <i>said<\/i> they were being prevented from coming in to work due to icy roads. Either way, the Scripting Guy who writes this column largely has the place to himself.<\/p>\n<p>You know those movies where a kid accidentally gets locked in a toy store or a candy store overnight? Well, having a Microsoft building all to yourself is almost as much fun.<\/p>\n<p>Almost. <\/p>\n<p>What\u2019s that? Doesn\u2019t the Scripting Guy who writes this column live on a side street that can be treacherous driving even when there <i>isn\u2019t<\/i> ice or snow on the road? Couldn\u2019t <i>he<\/i> have legitimately stayed home from work due to icy conditions? Wouldn\u2019t that have made more sense than walking a mile and a half to the bus stop and then standing around waiting for the bus to finally come crawling in? And then, after enduring all that hardship, his reward is that he gets to spend the day working? Shouldn\u2019t <i>he<\/i> have just stayed in bed this morning, like everyone else?<\/p>\n<p>Oh, sure: <i>now<\/i> you tell him! <\/p>\n<p>Oh, well. As long as we <i>did<\/i> make it in this morning we might as well show you a script that can change the text for the Marquee screen saver. As it turns out, each time the Marquee screen saver starts up it checks the registry to determine which text it should display. That means that all we have to do to modify that text is modify the appropriate registry value. How hard is that? Not very hard at all:<\/p>\n<pre class=\"codeSample\">Const HKEY_CURRENT_USER = &amp;H80000001\nstrComputer = \".\"\nSet objRegistry = GetObject(\"winmgmts:\\\\\" &amp; strComputer &amp; \"\\root\\default:StdRegProv\")\nstrKeyPath = \"Control Panel\\Screen Saver.Marquee\"\nstrValueName = \"Text\"\nstrStringValue = FormatDateTime(Date, vbLongDate)\nobjRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strStringValue\n<\/pre>\n<p>As you can see, we begin by defining a constant named HKEY_CURRENT_USER and setting the value to &amp;H80000001; we\u2019ll use this constant later on to tell the Standard Registry provider which registry hive we want to work with. (That\u2019s right: we\u2019re going to work with the HKEY_CURRENT_USER hive. How did you know that?)<\/p>\n<p>After defining the constant we then connect to the WMI service on the local computer (although this script can also be run against a remote computer; just assign the name of that computer to the variable strComputer). The big thing to watch out for here? We need to connect to the <b>StdRegProv<\/b> class, which happens to live in the <b>root\\default<\/b> namespace. That\u2019s different from the WMI classes used in the typical system administration script, classes that are almost always found in the root\\cimv2 namespace. Just something to keep in mind.<\/p>\n<p>After we make the connection to the WMI service we then need to assign values to three different variables:<\/p>\n<table border=\"0\" cellSpacing=\"0\" cellPadding=\"0\">\n<tbody>\n<tr>\n<td class=\"listBullet\" vAlign=\"top\">\u2022<\/td>\n<td class=\"listItem\">\n<p><b>strKeyPath<\/b>, the path to the registry key within the HKEY_CURRENT_USER hive. Because we have to connect to the <b>Control Panel\\Screen Saver.Marquee<\/b> registry key it\u2019s only fitting and proper that we assign strKeyPath the value <i>Control Panel\\Screen Saver.Marquee<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"listBullet\" vAlign=\"top\">\u2022<\/td>\n<td class=\"listItem\">\n<p><b>strValueName<\/b>, the name of the actual registry value we want to change. To modify the screen saver text we need to modify the string (REG_SZ) value named Text. Thus we assign the string <i>Text<\/i> to strValueName.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"listBullet\" vAlign=\"top\">\u2022<\/td>\n<td class=\"listItem\">\n<p><b>strStringValue<\/b>, the new text for the screen saver. We\u2019ve gotten fancy here, making the current date the screen saver text. But not just the date: we\u2019re using the VBScript function <b>FormatDateTime<\/b> to give us a date that will look like this: <i>Wednesday November 29, 2006<\/i>. To get fancy output like that we simple pass two parameters to FormatDateTime: the value to be formatted (the VBScript function <b>Date<\/b>) and the kind of formatting we want to apply (the VBScript constant <b>vbLongDate<\/b>). Are there other date-time formats besides the so-called \u201clong\u201d format that we could apply using this method? You bet there are; take a peek at the <a href=\"http:\/\/null\/technet\/scriptcenter\/guide\/sas_vbs_snry.mspx\"><b>Microsoft Windows 2000 Scripting Guide<\/b><\/a> for details.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>After assigning values to our three variables we\u2019re ready to go ahead and change the text in the registry. To do that we simply call the <b>SetStringValue<\/b> method, passing four parameters:<\/p>\n<table border=\"0\" cellSpacing=\"0\" cellPadding=\"0\">\n<tbody>\n<tr>\n<td class=\"listBullet\" vAlign=\"top\">\u2022<\/td>\n<td class=\"listItem\">\n<p>The constant HKEY_CURRENT_USER<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"listBullet\" vAlign=\"top\">\u2022<\/td>\n<td class=\"listItem\">\n<p>The variable strKeyPath<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"listBullet\" vAlign=\"top\">\u2022<\/td>\n<td class=\"listItem\">\n<p>The variable strValueName<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"listBullet\" vAlign=\"top\">\u2022<\/td>\n<td class=\"listItem\">\n<p>The variable strStringValue<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>And that\u2019s all we have to do. Best of all, there\u2019s no need to log the user off and then have him or her log back on after making this change. Like we said, each time the Marquee screen saver starts up it grabs the latest settings \u2013 including the text to be displayed \u2013 from the registry. Consequently, this change takes effect the very next time the screen saver kicks off.<\/p>\n<p>As for life here in the arctic, well, right now the sun is shining. It\u2019s still cold, however, which means that the ice will probably melt during the day, the melted ice will refreeze over night, and then we\u2019ll get to do this all over again. What a glorious time of year, huh?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I change the text for the Marquee screen saver? &#8212; SJ Hey, SJ. Greetings from the frozen wasteland formerly known as Redmond, WA. On Monday night a freak November snowstorm hit the Seattle area. However, instead of leaving behind snow it left behind an inch or so of ice; ice [&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,31,26,3,5],"class_list":["post-65953","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-desktop-management","tag-operating-system","tag-registry","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I change the text for the Marquee screen saver? &#8212; SJ Hey, SJ. Greetings from the frozen wasteland formerly known as Redmond, WA. On Monday night a freak November snowstorm hit the Seattle area. However, instead of leaving behind snow it left behind an inch or so of ice; ice [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/65953","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=65953"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/65953\/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=65953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=65953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=65953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}