Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Quiet System Calls in C++ (http://www.go4expert.com/forums/quiet-calls-cpp-t4348/)

blackey 17May2007 23:39

Quiet System Calls in C++
 
Hello all

I am attempting to make quiet system calls from C++ in order to run a batch file without the user knowing. I am going to eventually make this cross platform (windows and linux) although for now i am currently looking for a windows solution.

So I guess i'm looking for two things...
1. To call a program from windows without the user knowing
2. C++ program to pause until the system call has completed

Ideas?

DaWei 18May2007 03:01

Re: Quiet System Calls in C++
 
See the "system" keyword, and output redirection.

blackey 18May2007 03:53

Re: Quiet System Calls in C++
 
the system keyword makes the command prompt box appear, this is what i am trying to avoid. I am trying shellExecute() with the hide flag, but the c++ app seems to not wait for the command to quit before continuing on, if this was fixed, i would be golden.

blackey 18May2007 05:40

Re: Quiet System Calls in C++
 
Code:

                string cmdline = "pscp.exe -r -batch -scp -pw \""+m_password+"\" \""+m_file+"\" \""+m_username+"\"@\""+m_host+"\":\""+m_remotedir+"\"";

                STARTUPINFO          si = { sizeof(si) };
                PROCESS_INFORMATION  pi;
                char                *szExe = (char *)cmdline.c_str();

                if(CreateProcess(0, (LPSTR)szExe, 0, 0, FALSE, 0, 0, 0, &si, &pi))
                {
                        WaitForSingleObject(pi.hProcess, INFINITE);
                        CloseHandle(pi.hProcess);
                        CloseHandle(pi.hThread);
                }

Thanks for the help


All times are GMT +5.5. The time now is 05:21.