How to use system environment variables in VS 2008 Post-Build events?

build-process, visual-studio

Solution

Did you try $(LHDLLDEPLOY) instead of %LHDLLDEPLOY%?

Problem

How do I use system environment variables in my project post-build events without having to write and execute an external batch file? I thought that it would be as easy as creating a new environment variable named `LHDLLDEPLOY` and writing the following in my post-build event textbox: ``` copy $(TargetPath) %LHDLLDEPLOY%\$(TargetFileName) /Y copy $(TargetName).pdb %LHDLLDEPLOY%\$(TargetName).pdb /Y ``` ...but alas, no. The build output shows that it wrote the files to the "`%LHDLLDEPLOY%`" folder (as "`1 file(s) copied`" twice), but the files are not in the equated path and there is not a new folder called "`LHDLLDEPLOY`" Where did they actually go, and how do I do this correctly? (UPDATE: Xavier nailed it. Also, his variable format of `$(LHDLLDEPLOY)` worked after I rebooted the machine to refresh the environment variables.) (UPDATE 2: Turns out that I did not have to reboot my machine. I just needed to make sure that I a) closed the Environment Variables list window, and b) closed/relaunched Visual Studio.)

Original source