Next Generation Emulation banner

1 - 6 of 6 Posts

·
Memories are all I have..
Joined
·
423 Posts
Discussion Starter #1
hey guys..im tryin to export the whole registry into a file using command line
i can do it for the individual branches but i cant seem to export the whole registry into one file?

Anyone knows how to do this? thanks
 

·
Registered
Joined
·
9,506 Posts
AFAIK it's:

regedit /E "c:\name of folder \nameof file.reg" HKEY_USERS

please note:

a) the quotes are required around the reg file
b) the registry is a hirarchical structure (very like linux's hfs, if I didn't know any better I say m$ based the registry on it :p). You only need to backup HKEY_USERS. All other root keys are actually soft links to keys within HKU.
c) Caps are necessary (not 100% sure about that, but why take the risk ;) )
 

·
Memories are all I have..
Joined
·
423 Posts
Discussion Starter #4
thanks beta, but that i know. Problem is i want to have All the registry keys in one reg file. Kinda like using regedit then ya export the My Computer thingy.

Regards

EDIT:
Oh yeah..cos im doing it from an external program. thats why..haha..
 

·
Registered
Joined
·
9,506 Posts
Oops, I used the new posts option and didn't notice the forum;)

Ok the easy way: just spawn regedit from above via ShellExecute() or ShellExecuteEx(). Here's my code for doing that (written in c++)

Code:
//backs up the specified keyName into regfile, in currentFolderPath
backupReg(CString keyName,CString regFile,CString currentFolderPath)
{
	CString commandLine;
	commandLine ="/E \""+  regFile +"\" " + keyName;
	SHELLEXECUTEINFO sei;
	ZeroMemory( &sei, sizeof(sei) );
	sei.cbSize=sizeof(sei);
	sei.fMask=SEE_MASK_NOCLOSEPROCESS;
	sei.lpVerb=_T("open");
	sei.lpFile=_T("regedit");
	sei.nShow=SW_SHOW;
	sei.lpParameters=_T(commandLine);
	sei.lpDirectory=currentFolderPath;

	if(!ShellExecuteEx(&sei)) 
    {	
		MessageBox(NULL,"Unable to backup " + keyName + " settings","Error",MB_OK|MB_ICONERROR);
		return -1;
	}
	else
	{
		WaitForSingleObject( sei.hProcess, INFINITE );
	}
    CloseHandle(sei.hProcess);
	return 0;
}
If you set keyName = "" it will backup everything, or set it to a specific branch for a partial backup. The trick to making this work is the WaitForSingleObject() function. This effectively pauses your apps execution until regedit has exited, meaning that the backup will have been flushed to disk before the function finishes (in order to prevent any potential problems).
 

·
Memories are all I have..
Joined
·
423 Posts
Discussion Starter #6
cool..haha. thanks beta. im doing this app in vb.net, but thanks for the idea with the WaitForSingleObject. I think .net should have a smiliar function. i'll go look it up.

Thanks!
 
1 - 6 of 6 Posts
Top