How do I use scripts to lock the taskbar?

Time:2021-7-26
Copy codeThe code is 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 the taskbar can be locked or unlocked by switching a value in the registry; More specifically, by switching registry values   Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskBarSizeMove。 Set the value to   0   To lock the taskbar; Set it to   one   You can unlock the taskbar. As you might expect, to lock the taskbar, our script just needs to   TaskBarSizeMove   The value of is set to   0   It’s all right.

To implement this function, the script first defines a   HKEY_ CURRENT_ USER   And set 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 a single user.) Then, we use the following two lines of code to connect to the server on the local computer   WMI   Services:

strComputer = “.”
Set objReg = GetObject(“winmgmts:\\” & strComputer & “\root\default:StdRegProv”)

But don’t worry; You are not limited to running the script locally. Instead, you can easily modify the script to run in a remote computer environment. To do this, simply assign the name of the computer to the variable   strComputer   Just. For example, the following code will bind to a file named   atl-ws-01   On your computer   WMI   Services:

strComputer = “atl-ws-01”
Set objReg = GetObject(“winmgmts:\\” & strComputer & “\root\default:StdRegProv”)

This is better than going to and from offices and locking manually   three hundred   reach   four hundred   Is the taskbar easier on this computer? We can’t draw this conclusion with certainty, but it does sound easier, doesn’t it?

Connecting to   WMI   After service, the registry path can be  ( Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced)   Assigned to a named   strKeyPath   Variable. Then we will change the actual registry value  ( TaskBarSizeMove)   Assigned to a named   ValueName   Variable. Finally, the value   0   Assigned to a named   dwValue   Variable. This variable represents the value we want to assign to   TaskBarSizeMove   Value of.  

Note: what if we want to unlock the taskbar instead of locking it? no problem; Just set the value   one   Assign to   dwValue   Just.

Now all we have to do is call   SetDWORDValue   Method to set a constant   HKEY_ CURRENT_ USER   And variables   strKeyPath、ValueName   and   dwValue   Pass as parameter:

objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName, dwValue

This is done, but you may have to sign out and then sign in again for the change to really take effect. Therefore, you may want to add this code to the logout script; In this way, the changes will take effect automatically when the user logs off. The taskbar will be locked the next time the user logs in.

How eager our script expert wants him to be here   ten   Such a script would have been written years ago. Of course, even so, he still had to copy the script to a floppy disk and take the floppy disk to and from the offices. In addition, there was neither   Windows   Script   Host   either   WMI, so running the script is still a little difficult. But these are just trivial things, and our script experts are bound to find a way to avoid such small problems.

Recommended Today

VBS obtains the operating system and its version number

VBS obtains the operating system and its version number ? 1 2 3 4 5 6 7 8 9 10 11 12 ‘************************************** ‘*by r05e ‘* operating system and its version number ‘************************************** strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _  & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”) Set colOperatingSystems = objWMIService.ExecQuery _  (“Select * from […]