1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Quiet System Calls in C++

Discussion in 'C++' started by blackey, May 17, 2007.

  1. blackey

    blackey New Member

    Joined:
    Mar 14, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    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?
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    See the "system" keyword, and output redirection.
     
  3. blackey

    blackey New Member

    Joined:
    Mar 14, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. blackey

    blackey New Member

    Joined:
    Mar 14, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    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
     

Share This Page