Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Executing a C Executable from Another C program

  • 21-03-2005 10:43am
    #1
    Closed Accounts Posts: 1,541 ✭✭✭


    Hello All,

    I am looking for help on executing a C executable from within another C program.

    Basically I want to execute an executable on the sly without the user really knowing that another C program is actually executing.

    Is this possible?

    Thanks for any help.

    Finn :)


Comments

  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    No doubt some call like exec() (I don't know any C) will do the job for you?


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus




  • Closed Accounts Posts: 447 ✭✭MickFarr


    You can using the CreateProcess function I showed you in your other post.

    add these 2 lines
    si.dwFlags = STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_HIDE;

    For testing swap SW_HIDE with SW_NORMAL
    DWORD ExitCode;
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    
    
    memset(&si, 0, sizeof(si));
    memset(&pi, 0, sizeof(pi));
    si.cb = sizeof(si);
    si.dwFlags      =   STARTF_USESHOWWINDOW;
    si.wShowWindow  =   SW_HIDE;
    
    // Create the process. 
    if(!CreateProcess(NULL, "C:\\Program Files\\Internet Explorer\\iexplore.exe www.boards.ie",NULL,NULL,FALSE,CREATE_NO_WINDOW,NULL,NULL,&si,&pi))
       AfxMessageBox("CreateProcess failed.");
    
    // Close process. 
    GetExitCodeProcess(pi.hProcess, &ExitCode);
    TerminateProcess(pi.hProcess, ExitCode);
    


  • Closed Accounts Posts: 447 ✭✭MickFarr


    I hope your doing something naughty! :D


  • Registered Users, Registered Users 2 Posts: 4,003 ✭✭✭rsynnott


    finnpark wrote:
    Hello All,

    I am looking for help on executing a C executable from within another C program.

    Basically I want to execute an executable on the sly without the user really knowing that another C program is actually executing.

    Is this possible?

    Thanks for any help.

    Finn :)

    exec or system. Exec's probably handier if you want to provide arguments.


  • Advertisement
  • Closed Accounts Posts: 1,541 ✭✭✭finnpark


    Thanks All,

    Your help appreciated. All solutions suggested here work. In the end I am using system("name.exe"); as it is the handiest.

    Thanks again and yes I am am being very naughty. :D


Advertisement