I am creating an Envoirment var using a bat file and the command is below:
REG ADD HKCU\Environmen开发者_StackOverflowt /v DSPATH /t REG_SZ /d %cd%\DSClient.exe
This works fine but only after a logoff. Is there a way it can take effect without logging off.
You can use Setx command to modify environment variables in the user or system environment, without requiring programming or scripting.
Programmatically, to effect these changes without having to log off, broadcast a WM_SETTINGCHANGE
message to all windows in the system, so that any interested applications (such as Windows Explorer, Program Manager, Task Manager, Control Panel, and so forth) can perform an update.
See:
- How to propagate environment variables to the system
- Refreshing environment variables from the command prompt
精彩评论