私は16進値を持っていると聞きました。元の値が何であったかわかりません:
[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
これらの値をレジストリに追加したいので、コマンドプロンプトと管理者権限を次のコマンドでユーザー名に使用してみました:
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\ESET\ESET Security\CurrentVersion\Plugins\01000400\Profiles\@My profile /v Username /d test /f
それは魅力のように機能しました。次に、VS2010 の app.manifest ファイルに次の行を追加しました。
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
管理者権限を取得するために、このサイトで見つけた次のコマンドを使用しました。
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;
}
「操作は正常に完了しました」と返されますが、レジストリには何も変更されていません
C#関数を使用して値をレジストリに直接設定しようとしましたが、うまくいきませんでした。
ここで何が問題なのですか?これらの値をレジストリに設定するにはどうすればよいですか? プログラムが管理者として起動されている場合でも、プログラムではなく手動でコマンドを入力すると、コマンドプロンプトで機能するのはなぜですか?
編集済み:
私はこのコマンドを試しました:
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\ESET\ESET Security\CurrentVersion\Plugins\01000400\Profiles\@My profile /v Username /d test /f
そしてこれさえ
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\ESET\ESET Security\CurrentVersion\Plugins\01000400\Profiles\@My profile" /v Username /d test /f
そして、パスワードの魔女に何を使用すればよいかわかりません。
編集済み:
.reg ファイルを使用してみましたが、内容は次のとおりです。
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
次のコードを使用して実行しましたが、管理者権限でも機能しません。
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!");
}
操作が正常に完了したことを常に示しています。しかし、私はレジストリ値を変更しません。