Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   How can I add %ProgramFiles% to a system() call? (http://www.go4expert.com/forums/i-add-programfiles-t17004/)

Panarchy 21Apr2009 08:59

How can I add %ProgramFiles% to a system() call?
 
Hello

How can I add %ProgramFiles% to a system() call?

Here is my current code (using Dev-C++);

Code:

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    system("diskmgmt.msc");
    system(""%ProgramFiles%"\\Symantec\\LiveUpdate\\LUALL.exe");
    system("PAUSE");
    return EXIT_SUCCESS;
}

Please tell me how to get this line: system(""%ProgramFiles%"\\Symantec\\LiveUpdate\\LU ALL.exe"); to work.

Thanks in advance,

Panarchy

PS: Once I've gotten this to work, I'd also like to know how to stop the command prompt window from appearing.

xpi0t0s 21Apr2009 21:52

Re: How can I add %ProgramFiles% to a system() call?
 
Looks from your other post like you've already sussed it but as with the backslash you also have to escape quotes to include them in a string.

You want system to execute the following:
Code:

"%ProgramFiles%\Symantec\LiveUpdate\LUALL.exe"
So the code to do this is:
Code:

system("\"%ProgramFiles%\\Symantec\\LiveUpdate\\LUALL.exe\"");

Panarchy 22Apr2009 02:57

Re: How can I add %ProgramFiles% to a system() call?
 
Thanks


All times are GMT +5.5. The time now is 09:37.