ManagementClass ObjManagementClassRegistry =
new
ManagementClass(_objPublicManagementScope,
new
ManagementPath(
"
StdRegProv"
),
null
);
ManagementBaseObject inParams = ObjManagementClassRegistry.GetMethodParameters(
"
GetStringValue"
);
inParams[
"
hDefKey"
] =
0x80000002
;
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);
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));
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.