hear i have a hex value, i don't know what was the original value just this :
[HKEY_LOCAL_MACHINE\SOFTWARE\ESET\ESET Security\CurrentVersion\Plugins\01000400\Profiles\@My profile]
"Username"="test"
"Password"=hex:50,d6,e6,e9,ee,f0,cf,f2,6e,64,03,ad
I want to add these values to registry, I tried using command promp and administrator Privileges with the following command for username :
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\ESET\ESET Security\CurrentVersion\Plugins\01000400\Profiles\@My profile /v Username /d test /f
it worked like a charm. Then I added the following line to app.manifest File in VS2010 :
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
in order to get administrative privileges and I used the following command witch i found in this site :
private string GETCMD(string com)
{
string tempGETCMD = null;
Process CMDprocess = new Process();
System.Diagnostics.ProcessStartInfo StartInfo = new System.Diagnostics.ProcessStartInfo();
StartInfo.FileName = "cmd"; //starts cmd window
StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
StartInfo.CreateNoWindow = true;
StartInfo.RedirectStandardInput = true;
StartInfo.RedirectStandardOutput = true;
StartInfo.UseShellExecute = false; //required to redirect
CMDprocess.StartInfo = StartInfo;
CMDprocess.Start();
System.IO.StreamReader SR = CMDprocess.StandardOutput;
System.IO.StreamWriter SW = CMDprocess.StandardInput;
SW.WriteLine(com);
//insert your other commands here
SW.WriteLine("exit"); //exits command prompt window
tempGETCMD = SR.ReadToEnd(); //returns results of the command window
SW.Close();
SR.Close();
return tempGETCMD;
}
It returns that " The operation completed successfully " but nothing is changed in registry
I tried setting value directly to registry using c# functions but it didn't work.
whats wrong here? how i can set these values to registry ? why it is working by command prompt when I type the command manually but not programmatic, even when the program is started as administrator?
EDITED :
I tried this command :
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\ESET\ESET Security\CurrentVersion\Plugins\01000400\Profiles\@My profile /v Username /d test /f
AND even this
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\ESET\ESET Security\CurrentVersion\Plugins\01000400\Profiles\@My profile" /v Username /d test /f
AND i don't know what to use for password witch is in hex.
EDITED :
I tried using .reg file hear is the content :
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\ESET\ESET Security\CurrentVersion\Plugins\01000400\Profiles\@My profile]
"Username"="test"
"Password"=hex:50,d6,e6,e9,ee,f0,cf,f2,6e,64,03,ad
and i used following code to execute it but it doesn't work even with administrator privileges:
if (!String.IsNullOrEmpty(res))
{
string path = Path.GetTempPath() + "ajdm4SjhCHGS44AhhdJ892.reg";
File.WriteAllText(path, res);
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = "regedit.exe";
// start.Arguments = " -s " + path;
start.Arguments = " " + path;
Process proc = Process.Start(start);
MessageBox.Show("Done!");
}
it always shows that operation is completed successfully . but i does not change the registry values.