HKEY_LOCAL_MACHINE Registry Access

R

Ricardo Santos

I've got 2 solutions for your problem:

1st and the simplest:

RegistryPermission rpWrite = new
RegistryPermission(RegistryPermissionAccess.AllAccess,
@"HKEY_LOCAL_MACHINE\SOFTWARE\ODBC");
RegistryKey local =
RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, scMachine);
RegistryKey rkodbc = local.OpenSubKey("SOFTWARE", true);

and if you are in a diferent domain or not in a domain you can add a IPC
net use like this, where the path is @"\\MachineNameorIP\IPC$":

String cmdString = String.Format("net use {0} /user:{1}
{2}", path, username, password);
ManagementClass processClass = new
ManagementClass("Win32_Process");
object[] methodArgs = { cmdString, null, null, 0 };
object result = processClass.InvokeMethod("Create",
methodArgs);
 
R

Ricardo Santos

I've got 2 solutions for your problem:

1st and the simplest:

RegistryPermission rpWrite = new
RegistryPermission(RegistryPermissionAccess.AllAccess,
@"HKEY_LOCAL_MACHINE\SOFTWARE\ODBC");
RegistryKey local =
RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, scMachine);
RegistryKey rkodbc = local.OpenSubKey("SOFTWARE", true);

and if you are in a diferent domain or not in a domain you can add a IPC
net use like this, where the path is @"\\MachineNameorIP\IPC$":

String cmdString = String.Format("net use {0} /user:{1}
{2}", path, username, password);
ManagementClass processClass = new
ManagementClass("Win32_Process");
object[] methodArgs = { cmdString, null, null, 0 };
object result = processClass.InvokeMethod("Create",
methodArgs);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top