I have a program in C# and I am trying to write it in C++.
Somewhere in my app I have to run a command. In C++ I am trying to do it using system()
To run the command I have to give the absolute path. For example:
system("\"C:\\Documents and Settings\\myUser\\myProject\\app.exe\" -vb \"C:\\Documents and Settings\\myUser\\file.txt\"");
So, I am trying to run the exe called app.exe and it requires a file as parameter that I call using -vb. If I enter that command through the console, it works properly. But through the system() method it´s not working. The error says: 'C:\Documents' is not a command. If I use 'cout' to see exactly what is being sent, I get:
"C:\Documents and Settings\myUser\myProject\app.exe" -vb "C:\Documents and Settings\myUser\file.txt"
and If I type it through the console it works perfectly.
I also tried
"C:\Documents and Settings\myUser\myProject"\app.exe -vb "C:\Documents and Settings\myUser\file.txt" and other variations.
The problem is that I put "" between the path to the app.exe.
This command also works in C#. But there I use ProcessStarInfo.
I hope someone helps me.
Thx a lot.