I have a C++ program I created in visual studio and has issues when I save it on the server (to run as an .exe. The server doesn't have VS, so I tried it as an .exe. The program creates .txt file (or if one exists, it will overwrite it) and emails that new file as an attachment. Here's where it goes haywire: I can double click on the program and it will create a .txt and send the email off, but if I have the task scheduler do it, it will not overwrite the .txt file (or even create a new .txt file if I delete the current one). If the old .txt file is there, the program will attach *that* file and send the email off. 

So, I'm wondering if there's another way to have this program work? 

The server is Microsoft Sql Server 2008