Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to take image or make backup from reg files please help
thanks
Posted
Comments
mohammed besher 1-Dec-12 15:55pm    
thanks but i want to take backup as reg file not as xml
mohammed besher 2-Dec-12 4:52am    
I found code but it doesn't work with me
string Command = ("/C regedit.exe /e " + @"""" + ModernTechBU + @"\CurrentUser.Reg" + @"""" + CurrentUser);

if (Directory.Exists(ModernTechBU)==false)
{
Directory.CreateDirectory(ModernTechBU);
}

System.Diagnostics.Process.Start("CMD.exe", Command);
RegCall.Close();
mohammed besher 2-Dec-12 5:27am    
can any body help me to understand this code please help
public void ExportKey(string RegKey, string SavePath)
{
string path = "\"" + SavePath + "\"";
string key = "\"" + RegKey + "\"";

var proc = new Process();
try
{
proc.StartInfo.FileName = "regedit.exe";
proc.StartInfo.UseShellExecute = false;
proc = Process.Start("regedit.exe", "/e " + path + " " + key + "");

if (proc != null) proc.WaitForExit();
}
finally
{
if (proc != null) proc.Dispose();
}

}

Here is an article on creating a backup: Import/Export registry sections as XML[^]
 
Share this answer
 
From a persual of the documentation it looks like some P/Invoking via RegSaveKeyEx and RegRestoreKey will be required.

RegSaveKeyEx is said to Save the specified key and all of its subkeys and values to a registry file, in the specified format where the format may be "the standard format", "the latest format" or "the not compressed format".
http://msdn.microsoft.com/en-us/library/ms724917(v=vs.85).aspx[^]

As an alternative you could use reg.exe via the System.Diagnostics.Process class.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/reg.mspx?mfr=true[^]

Alan
 
Share this answer
 
Comments
mohammed besher 2-Dec-12 4:42am    
thanks i want C# code that take image from reg files which is same as registry editor
Alan N 2-Dec-12 6:29am    
The export format of reg.exe and regedit.exe are the same but reg.exe has the advantage of having a comprehensive and fully documented command line.
Although I haven't tested RegSaveKeyEx I would expect the standard format to be the same too.
Any of these techniques could be coded in C#. What is the problem?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900