I think this will not work the way you tried it, using
set
within the cmd.exe shell, the change will not be globally visible.
Try the
setx.exe
command, this will provide a change of the environment variable that is available to other processes.
See
http://stackoverflow.com/questions/3803581/setting-a-system-environment-variable-from-a-windows-batch-file[
^] for more details.
For your example this would be (the environment variable will be visible to all users on this machine):
ShellExecute(0, _T( "open" ), _T( "setx.exe" ), _T( "-m ALLUSERSPROFILE C:\Program" ), 0, SW_SHOWNA);