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

后端 未结 2 936
轻奢々
轻奢々 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 20:03

    InstallShield users using InstallShield 2010 or later.

    Important: The InstallScript Engine has changed since Version 2010 for Unicode.

    So using POINTER pEnv; will no longer work. You must use WPOINTER pEnv; instead. I personally use InstallShield 2013 and everything I found suggested the "POINTER approach", but this a piece of legacy code that does not translate to later versions.

    I use the following InstallScript function in InstallShield 2013:

    // Flush the NT registry to all applications.
    function RefreshEnvironment()
        STRING szEnv;
        WPOINTER pEnv;
    begin     
        szEnv = "Environment";
        pEnv = &szEnv;
        SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, pEnv);
    end;
    

    And for my defines I use:

    // defines
    #define WM_SETTINGCHANGE 0x001A
    #define HWND_BROADCAST 0xffff
    

    So the key here is broadcast WM_SETTINGCHANGE to all top-level windows. This way they are aware that a system-wide change has been made.

提交回复
热议问题