ok so im trying to make a program to read the output from a command using system() and i chose ipconfig as the command. to make it output to a file i used simple command prompt syntax, and it works, but only when i build and run it from my compiler (im using VC++ Express 2008). When i run it from the executable in my projects debug folder i get this message: "The process cannot access the file because it is in use by another process". Very odd. Then i tried using another command, i chose "pause", and it worked as expected and the output was in the file. Even more odd. I have restarted my computer and run the executable before doing anything else and that didnt work, i have checked task manager and it says there are no tasks. One more thing, the code does create an empty file and when i tried to delete it, it said that the file was in use by windows command prompt (or something like that) even though nothing was running. This does not happen anymore for reasons unknown. i think it stopped after i ran windows in safe mode. Anyways i hope someone can help with my problem. The program is just the one line of code: system("ipconfig>output.txt"); (and return 0;). thx in advance for any help
The '>' character redirects the output to the file specified after it instead of the consule. If you have declared output.txt in anyway in your code, even as ofstream then it will not work. Of course the exact error will help to. Also OS ver. and AV
i use output.txt afterwards with ifstream. there is no error code, when i run it from the stand alone executable it shows me the message "The process cannot access the file because it is in use by another process" but if i build and run it in my IDE (VC++ Express 2008) it all works perfectly. Also i went and compiled and ran the exact same code in Microsoft Visual Studio 2003 and the application file works as it should with the exectuable from VC++ Express 2008. Im using Windows 7 and i dont know what AV is