In addition to the above responses, you could also try: (I know WinExec is old but since it works still) WinExec("cmd /c ren c:\\a.txt b.txt", SW_HIDE);
It is the /C switch which causes cmd.exe to terminate after executing the command. And the second parameter to WinExec: SW_HIDE causes the window not to be shown.
If the program should run on Win9X also, then make it command.com instead of cmd.exe.
There was a problem with my program that it always return file pointer = NULL on the second (and further) attemps of openning file. So I tried to print out what error occured by using this command:
String error = strerror(errno) ;
The 'bad file number' was the message that I got in the string error.