// Create Defaults

    Requires(20150217);

    Prompt("This macro will create a default configuration... %\ %\>
                       Continue?",1,0);

    PushTagsandRegisters;

    ResetConsole;

    StartWorking('Creating Default Settings...');
    ProcessMessages;
    SaveSettings;
    SaveAll;
    // Preferences Dialog
    IfFileExists("%b\ConfigEx\UserPreferences.ini",>
      !'ExportPreferences("%b\ConfigEx\UserPreferences.ini");');
    // Load Defaults
    LoadConfig("%B\ConfigEx\Colors.ini");
    LoadConfig("%B\ConfigEx\Images.ini");
    LoadConfig("%B\ConfigEx\MainMenu.ini");
    LoadConfig("%B\ConfigEx\PopupMenus.ini");
    LoadConfig("%B\ConfigEx\Toolbar.ini");
    LoadConfig("%B\ConfigEx\GUI.ini");
    LoadConfig("%B\ConfigEx\DocTabs.ini");
    LoadConfig("%B\ConfigEx\DocList.ini");
    LoadConfig("%B\ConfigEx\StatusBar.ini");
    LoadConfig("%B\ConfigEx\Bookmarks.ini");
    LoadConfig("%B\ConfigEx\Input.ini");
    LoadConfig("%B\ConfigEx\Tree.ini");
    LoadConfig("%B\ConfigEx\Gather.ini");
    LoadConfig("%B\ConfigEx\Folding.ini");
    LoadConfig("%B\ConfigEx\Wrapping.ini");
    LoadConfig("%B\ConfigEx\Paragraphs.ini");
    LoadConfig("%B\ConfigEx\Environments.ini");
    LoadConfig("%B\ConfigEx\WordCount.ini");
    LoadConfig("%B\ConfigEx\Font.ini");
    LoadConfig("%B\ConfigEx\Tabs.ini");
    LoadConfig("%B\ConfigEx\Caret.ini");
    LoadConfig("%B\ConfigEx\Fonts.ini");
    LoadConfig("%B\ConfigEx\Editor.ini");
    LoadConfig("%B\ConfigEx\MouseInterface.ini");
    LoadConfig("%B\ConfigEx\Modes.ini");
    LoadConfig("%B\ConfigEx\Defaults.ini");
    LoadConfig("%B\ConfigEx\Templates.ini");
    LoadConfig("%B\ConfigEx\Find.ini");
    LoadConfig("%B\ConfigEx\Find in Files.ini");
    LoadConfig("%B\ConfigEx\Replace.ini");
    LoadConfig("%B\ConfigEx\Incremental Search.ini");
    LoadConfig("%B\ConfigEx\Errors.ini");
    LoadConfig("%B\ConfigEx\Delimiters.ini");
    LoadConfig("%B\ConfigEx\AutoComplete.ini");
    LoadConfig("%B\ConfigEx\ActiveStrings.ini");
    LoadConfig("%B\ConfigEx\Abbreviations.ini");
    LoadConfig("%B\ConfigEx\Language.ini");
    LoadConfig("%B\ConfigEx\Unicode.ini");
    LoadConfig("%B\ConfigEx\Sorting.ini");
    LoadConfig("%B\ConfigEx\TranslationTables.ini");
    LoadConfig("%B\ConfigEx\Dictionaries.ini");
    LoadConfig("%B\ConfigEx\Spelling.ini");
    LoadConfig("%B\ConfigEx\Suggestions.ini");
    LoadConfig("%B\ConfigEx\IgnoredText.ini");
    LoadConfig("%B\ConfigEx\SpellingErrors.ini");
    LoadConfig("%B\ConfigEx\CompoundedWords.ini");
    LoadConfig("%B\ConfigEx\ColorEffects.ini");
    LoadConfig("%B\ConfigEx\BackgroundSchemes.ini");
    LoadConfig("%B\ConfigEx\ColorGrid.ini");
    LoadConfig("%B\ConfigEx\Selections.ini");
    LoadConfig("%B\ConfigEx\FilterSets.ini");
    LoadConfig("%B\ConfigEx\Switches.ini");
    LoadConfig("%B\ConfigEx\Keywords.ini");
    LoadConfig("%B\ConfigEx\Columns.ini");
    LoadConfig("%B\ConfigEx\Backup.ini");
    LoadConfig("%B\ConfigEx\AutoSave.ini");
    LoadConfig("%B\ConfigEx\Folders.ini");
    LoadConfig("%B\ConfigEx\FileStatus.ini");
    LoadConfig("%B\ConfigEx\Project.ini");
    LoadConfig("%B\ConfigEx\Forms.ini");
    LoadConfig("%B\ConfigEx\Sounds.ini");
    LoadConfig("%B\ConfigEx\Preferences.ini");
    LoadConfig("%B\ConfigEx\Options.ini");
    LoadConfig("%B\ConfigEx\Events.ini");
    LoadConfig("%B\ConfigEx\Config.ini");
    LoadConfig("%B\ConfigEx\PrintSchemes.ini");
    LoadConfig("%B\ConfigEx\Print Schemes\PrintDefault.ini");
    LoadConfig("%B\Config\Default\DefaultSettings.ini");
    // LoadConfig("%B\ConfigEx\UserPreferences.ini");
    // LoadConfig("%B\ConfigEx\Private.ini");
    ProcessMessages;

    // Create WinEdt.dnt ...
    ShowGUIPage(-1);
    ProcessMessages;
    ShowAdvancedOptions(-1);
    ProcessMessages;
    ShowTree(1);
    ProcessMessages;
    ShowConsole(1);
    ProcessMessages;
    ShowConsole(-1);
    ProcessMessages;
    SetVirginStart(1);
    Exe('%B\Exec\Default\Load Config.edt');
    SaveSettings;
    IfStr('%b','%B','<>',>
      !|CopyFile('%b\WinEdt.dnt','%B\WinEdt.dnt',1,1);|);

    // Preferences Dialog
    ExportPreferences("%B\ConfigEx\UserPreferences.ini");

    GetDate(1,"yyyy-mm-dd, hh:mm.ss");
    WriteFile("%C\$Date Stamp.dat","%!1");

    // Copy Files!
    GetFilePath("%B",0);
    GetFilePath("%!0",1);
    LetReg(0,'%!1\WinEdt');

    // Update Working Documentation
    HTMLHelp('',1,6); // Close HTML Help
    IfFileOlder("%!1\Help\WinEdt.chw","%!1\Help\WinEdt.chm",>
      !"HTMLHelp('%!1\Help\WinEdt.chm',1,2);");
    HTMLHelp('',1,6); // Close HTML Help

    CopyFile('%!1\Help\Output\Edt.dic','%B\Dict\Edt\Edt.dic',1);
    CopyFile('%!1\Help\Output\Mcr.dic','%B\Dict\Edt\Mcr.dic',1);
    CopyFile('%!1\Help\Output\Mcr.dat','%B\Config\Edt\Mcr.dat',1);
    CopyFile('%!1\Help\Output\Mcr.lst','%B\Config\Edt\Mcr.lst',1);
    CopyFile('%!1\Help\WinEdt.chm','%B\Doc\Help\WinEdt.chm',1);
    CopyFile('%!1\Help\WinEdt.chw','%B\Doc\Help\WinEdt.chw',1);

    // Update Installation Folder
    CopyFile('%B\WinEdt-32.exe','%!0\WinEdt-32.exe',1);
    CopyFile('%B\WinEdt-64.exe','%!0\WinEdt-64.exe',1);
    CopyFile('%B\WinEdt.dnt','%!0\WinEdt.dnt',1);
    CopyFile('%B\WinEdtEx.dat','%!0\WinEdtEx.dat',1);
    CopyFile('%B\WinEdtMCR.dat','%!0\WinEdtMCR.dat',1);
    CopyFile('%B\WinEdtCMD.dat','%!0\WinEdtCMD.dat',1);
    CopyFile('%B\ConfigEx\UserPreferences.ini','%!0\ConfigEx\UserPreferences.ini',1);
    CopyFile('%B\Dict\Edt\Edt.dic','%!0\Dict\Edt\Edt.dic',1);
    CopyFile('%B\Dict\Edt\Mcr.dic','%!0\Dict\Edt\Mcr.dic',1);
    CopyFile('%B\Config\Edt\Mcr.dat','%!0\Config\Edt\Mcr.dat',1);
    CopyFile('%B\Config\Edt\Mcr.lst','%!0\Config\Edt\Mcr.lst',1);
    CopyFile('%B\Doc\Help\WinEdt.chm','%!0\Doc\Help\WinEdt.chm',1);
    CopyFile('%B\Doc\Help\WinEdt.chw','%!0\Doc\Help\WinEdt.chw',1);
    CopyFile('%B\Config\Default\$Date Stamp.dat','%!0\Config\Default\$Date Stamp.dat',1);
    CopyFile('%B\Config\Default\Create Copy.edt','%!0\Config\Default\Create Copy.edt',1);
    CopyFile('%B\Config\Default\Create Default.edt','%!0\Config\Default\Create Default.edt',1);
    CopyFile('%B\Config\Default\DefaultSettings.ini','%!0\Config\Default\DefaultSettings.ini',1);

    // Rebuild and Save Local Settings
    IfFileExists("%b\ConfigEx\UserPreferences.ini",!'LoadConfig("%b\ConfigEx\UserPreferences.ini");');
    IfFileExists("%b\ConfigEx\Private.ini",!'LoadConfig("%b\ConfigEx\Private.ini");');
    IfFileExists("%b\ConfigEx\UserPreferences.ini",>
      !'ExportPreferences("%b\ConfigEx\UserPreferences.ini");');
    SaveSettings;
    SavePrj;

    // Digital Signature for WinEdt (Class 3 Code Signing Certificate)
    LetReg(9, 'WinEdt');    // Executable(s) -32.exe and -64.exe
    LetReg(8, '\WinEdt');   // %C[startup folder]
    IfFileExists('%!1\Sign.edt',!'Exe("%!1\Sign.edt");');

    Wait(5000);

    // Compile the new build
    Assign('Main_File','%!F');
    SetMainFile("%!1\WinEdt.nsi");
    Assign("Old-NSIS-Switches","%$('NSIS-Switches');");
    Assign("NSIS-Switches","/DWINEDT_32");
    Exe('%b\Exec\Compile.edt'); // 32-bit
    Assign("NSIS-Switches","%$('Old-NSIS-Switches');");
    Exe('%b\Exec\Compile.edt'); // 64-bit
    SetMainFile("%$(|Main_File|);");   // Reset the Main File

    Wait(2500);

    // Digital Signature for Installer (Class 3 Code Signing Certificate)
    GetVersion(9);
    SubstituteInString('%!9','.','',0,9); // Remove the dot...
    LetReg(9, 'winedt%!9');  // Executable(s) -32.exe and -64.exe
    LetReg(8, '');           // %C[startup folder]
    IfFileExists('%!1\Sign.edt',!'Exe("%!1\Sign.edt");');

    // Start Explorer ... upload it!
    Run('explorer.exe /n,/e, "%!1"','%!1',0,0,'Windows Explorer');

    PopTagsandRegisters;

    StopWorking;

End;
