in reply to cls and perl

Your problem description speaks of STDIN. Your program as shown does not use STDIN, and does not pass anything to vsh's STDIN. Why do you think this has anything to do with STDIN? At a glance, tour program looks fine, except I don't know what SFXCL.exe and vsh are and what they are expecting. Can you get it to work from the prompt? Can you show us what commands you entered at the prompt and what you typed between them?