{	//before restart
	Filename tfn = GeGetStartupWritePath() + "template.c4d";
	Filename tfn_ret = GeGetStartupWritePath() + "template_ret_rs1.c4d"; //GeGetTimer();
	if(GeFExist(tfn)) GeFCopyFile(tfn,tfn_ret,GE_FCOPY_OVERWRITE); //GeFRename

	Filename lfn = GeGetStartupWritePath() + "prefs" + "template.l4d"; //<<< Save As StartupLayout
	Filename lfn_ret = GeGetStartupWritePath() + "prefs" + "template_ret_rs1.l4d";
	if(GeFExist(tfn)) GeFCopyFile(lfn,lfn_ret,GE_FCOPY_OVERWRITE); //GeFRename
	
	///Save As Template
	const Filename filename = GeGetStartupWritePath() + "template.c4d";
	BaseDocument *doc = GetActiveDocument();
	if(doc && SaveDocument(doc,filename,SAVEDOCUMENTFLAGS_0,FORMAT_C4DEXPORT))	{
		GePrint(filename.GetString() + " saved.");
	}
	
	CallCommand( 12672 ); // Save as Startup Layout  // Saves the current layout as startup layout
	
	RestartApplication();
}
