Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vbs to realize the screen saver used when configuring unmanned logged on computer

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to use vbs to configure unmanned login computer screen saver", the content is easy to understand, clear, hope to help you solve doubts, the following let Xiaobian lead you to study and learn "how to use vbs to configure unmanned computer screen saver used when the use of this article" it.

The code is 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 is very similar to many other registry modification scripts we have shown you in the past, with one special change. In previous scripts, we always defined a constant first, telling the script that we were going to deal with 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 make to the current user or to the computer itself. However, notice the first line of this script:

Const HKEY_USERS = & H80000003

Here's the secret: this time we're dealing with the HKEY_USERS registry hive. Among other things, the HKEY_USERS configuration unit provides you with a place where the settings configured can be applied to any user who logs in to the computer, not just a particular user. In other words, if you configure a screen saver using HKEY_USERS, the screen saver is the default screen saver and will be applied to any new user who logs in to the computer. (unless the user explicitly configures another screen saver, the default screen saver will continue to be applied. Similarly, this default screen saver is used when no one logs on to the computer

Isn't that cool? Incidentally, you can also use the registry hive to configure the wallpaper displayed on the login screen; simply set the registry value HKEY_USERS\ .default\ Control Panel\ Desktop\ Wallpaper to the appropriate file path. Code similar to the following:

The copy code is 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 defining the constant, the next step is to connect to the WMI service on the local computer (although this script also works well on the remote computer). Then, assign values to the following three different variables:

The path to the registry key within 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-the new value to assign to the SCRNSAVE.EXE. In this script, this value is the full path to this screen saver.

Finally, we call the SetStringValue method (passing the constant HKEY_USERS with these three variables as parameters), and we're done:

ObjReg.SetStringValue HKEY_USERS, strKeyPath, ValueName, strValue

Now, if you wait a few minutes after you log out, the script Center screen saver will run. (assume that the registry value ScreenSaveActive is set to 1; if set to 0, the screen saver is disabled. )

The above is all the contents of this article entitled "how to configure screen savers for unmanned logged-on computers with vbs". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report