How to programmatically change settings for WMI instead of using wmimgmt.msc snappin?
Normally you go this way:
- start -> run
- enter wmimgmt.m开发者_运维知识库sc and press enter
- riht click on "WMI Control" node -> properties
- on security tab click button security
- add new user
- for user you just add allow "Remote enable"
How can this be done programmatically(C# or vbs) ? I searched the web and found sometning about doing it by using WMIC, but I don't understand how to do it. Here are the links if they helps you. http://msdn.microsoft.com/en-us/library/aa393613%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/aa393611%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/aa822575%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/aa822576%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/aa394531%28v=VS.85%29.aspxThank you very much
I won't explain exactly how to do this, but since you are doing something that involves some good understanding of windows, programming and administering I will simply give you a link to the source code that you can adapt into your project to manage the WMI security:
http://www.codeproject.com/KB/system/WmiSecurity.aspx
Basically what you should note is the following paragraph:
So at this point, some examples should suffice to illustrate the use of the utility. Suppose you wanted to add the domain HelpDesk group to the CIMV2 and subsequent namespaces on the S223001 computer. Further, suppose this group should have the ability to remotely connect and read WMI objects. To do this:
WmiSecurity /C=S223001 /A /N=Root\CimV2 /M=MyDomain\HelpDesk:REMOTEACCESS /R
Hope that it can help.
Cheers.
There are many things you can do with WMI. WMI API for .net is the one you need. Here are few examples and links that may be useful to achieve your objectives.
http://msdn.microsoft.com/en-us/library/Aa394572
http://msdn.microsoft.com/en-us/library/aa393964%28v=vs.85%29.aspx#obtaining_data_from_WMI
WMI made it easy example: http://www.csharphelp.com/2006/10/wmi-made-easy-for-c/
Change users parental control settings using WMI in c#
http://www.codeproject.com/KB/system/cstcpipwmi.aspx
精彩评论