相关文章推荐
强悍的核桃  ·  c# - Cannot ...·  1 年前    · 
儒雅的硬币  ·  国产大模型百花齐放 ...·  1 年前    · 
深情的围巾  ·  Notify Update·  2 年前    · 
ManagementClass ObjManagementClassRegistry = new ManagementClass(_objPublicManagementScope, new ManagementPath( " StdRegProv" ), null ); ManagementBaseObject inParams = ObjManagementClassRegistry.GetMethodParameters( " GetStringValue" ); inParams[ " hDefKey" ] = 0x80000002 ; // HKEY_LOCAL_MACHINE; inParams[ " sSubKeyName" ] = @" SOFTWARE\Microsoft\Windows NT\CurrentVersion" ; inParams[ " sValueName" ] = " UBR" ; ManagementBaseObject ObjOutParams = ObjManagementClassRegistry.InvokeMethod( " GetDWORDValue" , inParams, null ); if (Convert.ToUInt32(ObjOutParams[ " ReturnValue" ]) == 0 ) var ddd = ObjOutParams[ " uValue" ]; What I have tried:
The problem I need to do is in the Microsoft.Management.Infrastructure assembly . I want to read the Subversion remotely from the operating system. Remote Registry and Remote PowerShell are not allowed :-(
I want to thank you in advance for your help
Greetings Brauschi string strComputer = " ComputerName" ; string strUser = " UserName" ; string strPassword = " UserPassword" ; string strDomain = " DomainName" ; SecureString securepassword = new SecureString(); foreach ( char c in strPassword) securepassword.AppendChar(c); CimCredential Credentials = new CimCredential(PasswordAuthenticationMechanism.Kerberos, strDomain, strUser, securepassword); WSManSessionOptions SessionOptions = new WSManSessionOptions() { DestinationPort = 5985 }; SessionOptions.AddDestinationCredentials(Credentials); CimSession SystemSession = CimSession.Create(strComputer, SessionOptions); bool Connected = SystemSession.TestConnection( out CimInstance TmpInstance, out CimException TmpExeption); // CLASSES_ROOT = 2147483648; // CURRENT_USER = 2147483649; // LOCAL_MACHINE = 2147483650; // USERS = 2147483651; // CURRENT_CONFIG = 2147483653; UInt32 RegRoot = 2147483650 ; CimMethodParametersCollection CimParams = new CimMethodParametersCollection(); CimParams.Add(CimMethodParameter.Create( " hDefKey" , RegRoot, CimFlags.In)); CimParams.Add(CimMethodParameter.Create( " sSubKeyName" , @" SOFTWARE\Microsoft\Windows NT\CurrentVersion" , CimFlags.In)); CimParams.Add(CimMethodParameter.Create( " sValueName" , " UBR" , CimFlags.In)); // GetStringValue = sValue // GetMultiStringValue = sValue // GetExpandedStringValue = sValue // GetDWORDValue = uValue // GetQWORDValue = uValue // GetBinaryValue = uValue CimMethodResult NameResults = SystemSession.InvokeMethod( new CimInstance( " StdRegProv" , @" root\default" ), " GetDWORDValue" , CimParams); string strUBR_RegistryValue = NameResults.OutParameters[ " uValue" ].Value.ToString();
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •