views:

133

answers:

1

In Visual Studio postbuild, I need to run a batch file. The solution is potentially on a different drive to that which Visual Studio is running from. In postbuild, how do I determine the drive letter that the solution is running from so I can change to that drive before running the batch file? At the moment, all I have is this:

CD $(ProjectDir)
$(ProjectDir)postbuild.bat

The problem is that changing directory when that directory is on a different drive does not change the current directory, as you have to manually change which drive you're on, e.g. like so:

E:\
CD $(ProjectDir)
$(ProjectDir)postbuild.bat

I can't guarantee what drive the solution is going to be on though, so I need to determine the drive via some kind of macro to ensure the postbuild.bat file will run from the currect location.

+3  A: 
CD /D $(ProjectDir)
Roger Lipscombe
You learn something new every day. cheers.
Nathan Ridley