How do I lock the taskbar with a script? _vbs

Source: Internet
Author: User
Copy Code code as follows:

HKEY_CURRENT_USER = &h80000001

StrComputer = "."
Set Objreg = GetObject ("winmgmts:\\" & StrComputer & "\root\default:StdRegProv")

strKeyPath = "software\microsoft\windows\currentversion\explorer\advanced"
VALUENAME = "Taskbarsizemove"
dwvalue = 0

Objreg.setdwordvalue HKEY_CURRENT_USER, strKeyPath, ValueName, dwvalue

It turns out that by switching a value in the registry, you can lock or unlock the taskbar, or rather, by switching the registry value software\microsoft\windows\currentversion\explorer\advanced\ Taskbarsizemove. Set the value to 0 to lock the taskbar, and set it to 1 to unlock the taskbar. As you might expect, to lock the taskbar, our script simply sets the Taskbarsizemove value to 0.

To implement this feature, the script first defines a constant named HKEY_CURRENT_USER and sets its value to &H80000001; we will use this constant to indicate which registry hive the script will process. (Locking and unlocking the taskbar is done for individual users.) We then use the following two lines of code to connect to the WMI service on the local computer:

StrComputer = "."
Set Objreg = GetObject ("winmgmts:\\" & StrComputer & "\root\default:StdRegProv")

But don't worry; you are not limited to running the script on this computer. It is easy to modify the script to run in a remote computer environment. To do this, simply assign the name of the computer to the variable strComputer. For example, the following code is bound to the WMI service on a computer named atl-ws-01:

StrComputer = "atl-ws-01"
Set Objreg = GetObject ("winmgmts:\\" & StrComputer & "\root\default:StdRegProv")

Is this easier than going back and forth to the offices and locking the taskbar on 300 to 400 machines manually? We can't exactly follow this conclusion, but it does sound a little easier, doesn't it?

After you connect to the WMI service, you can assign a registry path (software\microsoft\windows\currentversion\explorer\advanced) to a variable named strKeyPath. Then assign the actual registry value (Taskbarsizemove) that we want to change to a variable named ValueName. Finally, assign the value 0 to a variable named dwvalue. The variable represents the value we are assigning to taskbarsizemove.

Note: What if we want to unlock the taskbar instead of locking it? No problem, just assign a value of 1 to dwvalue.


All we have to do now is call the SetDWORDValue method and pass the constant HKEY_CURRENT_USER and variable strKeyPath, ValueName, and dwvalue as parameters:

Objreg.setdwordvalue HKEY_CURRENT_USER, strKeyPath, ValueName, dwvalue

That's it, but you might have to log off and log in again before the change really takes effect. Therefore, you might want to add the code to the logoff script, so that when the user logs off, the change takes effect automatically. The next time the user logs on, the taskbar will be locked.

How eager our Scripting Guys are to expect him to write such a script 10 years ago. Of course, even so, he still has to copy the script to a floppy disk, and then carry the floppy disk to and from the offices. In addition, there is no Windows script Host and no WMI at that time, so running the script has some difficulty. But these are just trivial things, and our Scripting Guys are bound to find a way to avoid such small problems.

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.