rv = m_reg->SetString(key, "CurrentProfile", profileName);
rv = m_reg->SetString(key, REGISTRY_CURRENT_PROFILE_STRING, profileName);
NS_IMETHODIMP nsProfile::MigrateProfile(const char* profileName){	nsresult rv = NS_OK;    PRBool openalready = PR_FALSE;     #if defined(DEBUG_profile)	printf("Inside Migrate Profile routine.\n" );#endif	nsFileSpec oldProfDir;	nsFileSpec newProfDir;	rv = GetProfileDir(profileName, &oldProfDir);	if (NS_FAILED(rv)) return rv;		// Create new profile dir path        NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);	if (NS_FAILED(rv) || !locator) return NS_ERROR_FAILURE;	    // Get current profile, make the new one a sibling...	nsCOMPtr<nsIFileSpec> newSpec;       	rv = locator->GetFileLocation(nsSpecialFileSpec::App_DefaultUserProfileRoot50, getter_AddRefs(newSpec));	if (!newSpec)	     return NS_ERROR_FAILURE;    	newSpec->GetFileSpec(&newProfDir);	newProfDir += profileName;	// Call migration service to do the work.	nsCOMPtr <nsIPrefMigration> pPrefMigrator;	rv = nsComponentManager::CreateInstance(kPrefMigrationCID,                                           nsnull,					NS_GET_IID(nsIPrefMigration),					getter_AddRefs(pPrefMigrator));    if (NS_FAILED(rv)) return rv;        	nsXPIDLCString oldProfDirStr;    nsXPIDLCString newProfDirStr;		rv = GetStringFromSpec(newProfDir, getter_Copies(newProfDirStr)); 	if (NS_SUCCEEDED(rv)) {               		rv = GetStringFromSpec(oldProfDir, getter_Copies(oldProfDirStr));               		if (NS_SUCCEEDED(rv)) {                             			rv = pPrefMigrator->AddProfilePaths(oldProfDirStr,  newProfDirStr);  // you can do this a bunch of times.      rv = pPrefMigrator->ProcessPrefs();		}	}	if (NS_FAILED(rv)) return rv;	//unmark migrate flag	if (NS_SUCCEEDED(rv))	{		// Check result.		if ( m_reg != nsnull ) 		{	        // Open the registry.			rv = m_reg->IsOpen( &openalready );					if ( !openalready )				rv = m_reg->OpenDefault();			if (NS_SUCCEEDED(rv))			{				nsIRegistry::Key key;				rv = m_reg->GetSubtree(nsIRegistry::Common, "Profiles", &key);				if (NS_SUCCEEDED(rv))				{			        nsIRegistry::Key newKey;					rv = m_reg->GetSubtree(key, profileName, &newKey);					if (NS_SUCCEEDED(rv))					{				        rv = m_reg->SetString( newKey, "migrated", "yes");						if (NS_SUCCEEDED(rv))						{							rv = m_reg->SetString(key, "CurrentProfile", profileName);																				if (NS_FAILED(rv))							{#if defined(DEBUG_profile)									printf("Profiles : Couldn't set CurrentProfile Name.\n");#endif					        }						}						else						{#if defined(DEBUG_profile)								printf("Profiles : Couldn't set migrate flag.\n");#endif						}						SetProfileDir(profileName, newProfDir);					}					else					{#if defined(DEBUG_profile)							printf("Profiles : Couldn't get profileName subtree.\n");#endif					}				}				else				{#if defined(DEBUG_profile)						printf("Registry : Couldn't get Profiles subtree.\n");#endif				}				if (!openalready)					m_reg->Close();			}			else			{	#if defined(DEBUG_profile)					printf("Couldn't open registry.\n");#endif			}		}	}	return rv;}