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 change the instructions of the computer

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to use vbs to change the computer instructions, I believe that most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Q:

Hello, script expert! When you use Windows Explorer to connect to a remote computer, you can see a description of that computer in the details pane. How do I change the description of my computer?

-- GF

A:

Hello, GF. Just to make sure that everyone knows what we're talking about, we won't talk about the "description" attribute in Active Directory, but about computer instructions that are broadcast across the network. (if what you really want to know is how to change the description property in Active Directory, see this "Hello, scripting expert!" Column. )

For example, in Windows XP, you can view the computer description by right-clicking my computer, clicking Properties, and then viewing the contents of the computer name tab of the system Properties dialog box:

As you mentioned, if you connect to the computer using Windows Explorer, the description also appears in the details pane:

We also think it's very exciting.

So how do you change the computer description? Well, you can start Regedit.exe and manually change the registry value HKEY_LOCAL_MACHINE\ System\ CurrentControlSet\ Services\ lanmanserver\ parameters\ srvcomment. Or run a script similar to the following script:

The code is as follows:

Const HKEY_LOCAL_MACHINE = & H80000002

StrComputer = "."

Set objRegistry = GetObject _

("winmgmts:\" & strComputer & "\ root\ default:StdRegProv")

StrKeyPath = "System\ CurrentControlSet\ Services\ lanmanserver\ parameters"

StrValueName = "srvcomment"

StrDescription = "Description changed programmatically"

ObjRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDescription

Of course it's easy; after spending so much time together, do you really think we will suddenly begin to provide complex and inexplicable answers to your questions? We first define a constant called HKEY_LOCAL_MACHINE and set its value to & H80000002; after a while, we will use this constant to tell the script which registry hive we are dealing with. We then connect to the WMI service (in this case, it is on the local computer, but it is almost as easy to modify the registry on the remote computer) and bind to the StdRegProv class. (and this class (as we've taken the trouble to tell you) happens to be in the root\ default namespace. )

Next, we assign values to three variables:

StrKeyPath = "System\ CurrentControlSet\ Services\ lanmanserver\ parameters"

StrValueName = "srvcomment"

StrDescription = "Description changed programmtically"

The variable strKeyPath represents the path within the HKEY_LOCAL_MACHINE section of the registry; strValueName represents the registry value to be changed (srvcomment); and strDescription, yes: strDescription represents the new computer description. You are very observant.

Note: what we want to say is that you are much better than us in this respect, but we don't want the manager to know anything about it. Indeed: for a Microsoft manager, knowing the situation will be the most important thing!

Now all we have to do is call the SetStringValue method, passing HKEY_LOCAL_MACHINE and our three variables as method parameters:

ObjRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDescription

A script like this really makes life meaningful, doesn't it?

Note: note that even if you make this change in the registry, the new instructions may not take effect until the computer is restarted. This is just a place to pay attention to.

The above is all the contents of the article "how to use vbs to change the computer". 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