Well the first thing I'd do is run your subst command on a command line and see if that works. If that doesn't work, something else must be wrong.
You could also try running it with the system() function and see what happens.
Oh, and are you running Vista? I'm not sure if you need Admin priviliges to do a subst, but that's just a thought.