Use the VBS implementation to configure the screen saver used when configuring an unattended computer _vbs

Source: Internet
Author: User
Ask:
Hello, Scripting Guy! I recently downloaded your "Script Center" screen Saver, which works great when someone logs on to the computer. But when no one is logged on, the computer uses a different screen saver. How do I get my computer to use the Script Center screen saver when no one is logged on?
--RF
For:
Hello, RF. You know, we've had this situation and you're probably trying to cheat the old Scripting Guys. For example, how do we know that the screen saver that you want to run when no one is logged on to your computer is our screensaver? Maybe you just flatter the Scripting Guys so that the Scripting Guys will answer your questions. After you've answered the question, you'll get rid of us and install some other screen saver related to scripting as the default screen saver. RF AH RF: Do you really think that the Scripting Guys are so simple minded to enjoy such a false compliment?
Well, you should think so, because we do:
Copy Code code as follows:

Const HKEY_USERS = &h80000003
StrComputer = "."
Set Objreg = GetObject ("winmgmts:\\" & StrComputer & "\root\default:StdRegProv")
strKeyPath = ". DEFAULT\Control Panel\Desktop "
VALUENAME = "Scrnsave." EXE "
strvalue = "C:\WINDOWS\System32\Script center.scr"
Objreg.setstringvalue HKEY_USERS, strKeyPath, ValueName, strvalue

As you can see, this is a WMI script for changing the registry. It's very similar to the many other registry modification scripts we've shown you in the past, but there's a special change. In previous scripts, we always first defined a constant, telling the script that we want to process the HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE registry hive. There is a good reason for this: we want to apply all the changes we have made to the current user or the computer itself. However, note the first line of this script:
Const HKEY_USERS = &h80000003
The secret is here: this time we're going to deal with the HKEY_USERS registry hive. In addition to other uses, the HKEY_USERS hive provides you with a place where the settings that are configured can be applied to any user who logs on to the computer, not just to a particular user. In other words, if you use HKEY_USERS to configure the screen saver, the screensaver is the default screen saver that is applied to any new users who log on to the computer. (unless the user explicitly configures another screen saver, the default screen saver continues to be applied.) Similarly, this default screen saver is used when no one is logged on to the computer.
Cool, huh? Incidentally, you can also use this registry hive to configure the wallpaper that is displayed on the login screen; hkey_users\ the registry value only. DEFAULT\Control Panel\desktop\wallpaper is set to the appropriate file path. Code similar to the following:
Copy Code code as follows:

Const HKEY_USERS = &h80000003
StrComputer = "."
Set Objreg = GetObject ("winmgmts:\\" & StrComputer & "\root\default:StdRegProv")
strKeyPath = ". DEFAULT\Control Panel\Desktop "
valuename = "Wallpaper"
strvalue = "C:\WINDOWS\System32\Script center.bmp"
Objreg.setstringvalue HKEY_USERS, strKeyPath, ValueName, strvalue

After you define a constant, you next connect to the WMI service on the local computer (although this script works equally well on the remote computer). Then, assign a value to the following three different variables:
The path of the registry key within the strkeypath-hkey_users. In this case, the path is. DEFAULT\Control Panel\Desktop.
ValueName-The name of the registry value to change (scrnsave. EXE).
strvalue-to be assigned to Scrnsave. The new value of the EXE. In this script, the value is the full path to this screen saver.
Finally, we're going to call the SetStringValue method (pass the constant hkey_users along with the three variables as arguments), and that's it:
Objreg.setstringvalue HKEY_USERS, strKeyPath, ValueName, strvalue
Now, if you wait a few minutes after you log off, you will run the Script Center screen saver. (Assuming that the registry value ScreenSaveActive is set to 1; If set to 0, this screen saver is disabled.) )
You know how easy this is? Oh, no, we're not talking about scripting (although the script is very simple); we're talking about how easy it is to get the answer to the question, and of course, the wording of your question is the right one. As is often said, everyone likes to hear compliments.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.