How Can I Change the Text for the Marquee Screen Saver?

How Can I Change the Text for the Marquee Screen Saver?

  • Comments 2
  • Likes
Hey, Scripting Guy! Question

Hey, Scripting Guy! How can I change the text for the Marquee screen saver?

-- SJ

SpacerHey, Scripting Guy! AnswerScript Center

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’re from the Midwest/Alaska/Norway/Greenland or anywhere else that doesn’t shut down completely just because you get a little ice and snow feel free to insert your favorite “People from Seattle are so wimpy” joke here.) Is it really that bad here? Well, let’s put it this way: people actually slept in their cars on the freeway last night: traffic wasn’t going anywhere and they were too far from home to walk. And so they spent the night sleeping in their cars on I-405.


Things aren’t 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’ 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 said 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.

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.


What’s that? Doesn’t the Scripting Guy who writes this column live on a side street that can be treacherous driving even when there isn’t ice or snow on the road? Couldn’t he have legitimately stayed home from work due to icy conditions? Wouldn’t 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’t he have just stayed in bed this morning, like everyone else?

Oh, sure: now you tell him!

Oh, well. As long as we did 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:

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."

strKeyPath = "Control Panel\Screen Saver.Marquee"
strValueName = "Text"
strStringValue = FormatDateTime(Date, vbLongDate)

objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strStringValue

As you can see, we begin by defining a constant named HKEY_CURRENT_USER and setting the value to &H80000001; we’ll use this constant later on to tell the Standard Registry provider which registry hive we want to work with. (That’s right: we’re going to work with the HKEY_CURRENT_USER hive. How did you know that?)

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 StdRegProv class, which happens to live in the root\default namespace. That’s 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.

After we make the connection to the WMI service we then need to assign values to three different variables:

strKeyPath, the path to the registry key within the HKEY_CURRENT_USER hive. Because we have to connect to the Control Panel\Screen Saver.Marquee registry key it’s only fitting and proper that we assign strKeyPath the value Control Panel\Screen Saver.Marquee.

strValueName, 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 Text to strValueName.

strStringValue, the new text for the screen saver. We’ve gotten fancy here, making the current date the screen saver text. But not just the date: we’re using the VBScript function FormatDateTime to give us a date that will look like this: Wednesday November 29, 2006. To get fancy output like that we simple pass two parameters to FormatDateTime: the value to be formatted (the VBScript function Date) and the kind of formatting we want to apply (the VBScript constant vbLongDate). Are there other date-time formats besides the so-called “long” format that we could apply using this method? You bet there are; take a peek at the Microsoft Windows 2000 Scripting Guide for details.

After assigning values to our three variables we’re ready to go ahead and change the text in the registry. To do that we simply call the SetStringValue method, passing four parameters:


The variable strKeyPath

The variable strValueName

The variable strStringValue

And that’s all we have to do. Best of all, there’s 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 – including the text to be displayed – from the registry. Consequently, this change takes effect the very next time the screen saver kicks off.

As for life here in the arctic, well, right now the sun is shining. It’s still cold, however, which means that the ice will probably melt during the day, the melted ice will refreeze over night, and then we’ll get to do this all over again. What a glorious time of year, huh?

Your comment has been posted.   Close
Leave a Comment
  • Hey, awesome script!

    It works great on a local machine, but even after defining the computer name in strComputer, I am unable to get it to work remotely. I'm copying the script to the user's local drive for now and using PSexec to run the script remotely.

    Any ideas on what is failing when trying to run it from my box on a remote user?

  • Sir , thanks for the script ...

    im looking for the same script but to change an ip port for the printer .

    its not working , any idea please ? its urgent .

    const HKEY_LOCAL_MACHINE = &H80000002

    strComputer = "."


    strKeyPath = "SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_169.254.110.14"

    strEntryName = "IPAddress"

    strStringValue = ""

    ObjRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strEntryName, strStringValue

    any help would be thanksufl ! regards ,

    mail me please at