Batch file can't immediately see environment variables created by InstallShield script

后端 未结 2 930
轻奢々
轻奢々 2021-01-06 19:50

We use InstallShield 2008 for our product installation. Product consists of several components. When a component is installed, a batch-file with some post-install r

2条回答
  •  醉梦人生
    2021-01-06 19:58

    I had the same problem with an earlier version of InstallShield. Here's the way I solved it (quick and dirty code).

    #define HWND_BROADCAST          0xffff
    #define WM_SETTINGCHANGE        0x001A
    function UpdateEnvironmentVariable(szKey, szValue)
      NUMBER nResult;
      STRING szEnv;
      POINTER pEnv;
    begin
      nResult = RegDBSetKeyValueEx(szKey, "PATH", REGDB_STRING, szValue, -1);
    
      szEnv = "Environment";                    
      pEnv = &szEnv;                  
      SendMessage (HWND_BROADCAST, WM_SETTINGCHANGE, 0, pEnv );
    end;
    

    The key is to use SendMessage. Hope it helps.

提交回复
热议问题