regReplacePath function

void regReplacePath(
  1. List<String> newPaths
)

Replaced the existing Windows PATH with newPaths.

WARNING: becareful using this method. If you get it wrong you can destroy your Windows PATH which will stop lots of things (everything?) from working. A WindowsException is thrown the call falls.

Implementation

void regReplacePath(List<String> newPaths) {
  // const char * what = "Environment";
  // DWORD rv;
  // SendMessageTimeout( HWND_BROADCAST, WM_SETTINGCHANGE, 0,
  // 						(LPARAM) what, SMTO_ABORTIFHUNG, 5000, & rv );

  regSetExpandString(
    HKEY_CURRENT_USER,
    'Environment',
    'Path',
    newPaths.join(Env().delimiterForPATH),
  );

  broadcastEnvironmentChange();
}