C. *_*oss 0 c# windows setup-project
我正在编写一个安装程序模块,我需要永久地向系统%PATH%变量添加一个值.如何从C#安装程序代码修改它?
Well, that's quite yucky. Modifying the PATH is about as evil a thing an installer could ever do. It has gotten a particularly bad rap because so many uninstallers destroy it, causing very hard to diagnose problems.
I think you'll need to write a custom action that modifies the registry. The system environment is stored in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment, Path value. You should force a reboot to make sure the new setting is effective.
And test the uninstall.
Seeing your comment to SLaks, use HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths instead.