Quiet System Calls in C++

blackey's Avatar, Join Date: Mar 2007
Go4Expert Member
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's Avatar, Join Date: Dec 2006
Team Leader
See the "system" keyword, and output redirection.
blackey's Avatar, Join Date: Mar 2007
Go4Expert Member
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's Avatar, Join Date: Mar 2007
Go4Expert Member
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