Hide CMD

Posted on 2007-08-04
Last Modified: 2013-11-17
How do i send CMD commands without having the window show up.
I need to execute ftp -s:myftpcommands.txt (upload to ftp files) without having the cmd window show.
Question by:Jammer1224
    LVL 30

    Expert Comment

    Have you tried WinExec with  SW_HIDE?
    LVL 86

    Expert Comment

    Create the process as "invisible", e.g.

    DWORD ExecuteAndWaitForCompletion   (   LPSTR   pszCmd)
       STARTUPINFO         si;

       BOOL                bRes;

       DWORD               dwCode  =   0;

       ZeroMemory  (   &si,    sizeof  (   STARTUPINFO));

       si.cb           =   sizeof  (   STARTUPINFO);
       si.dwFlags      =   STARTF_USESHOWWINDOW;
       si.wShowWindow  =   SW_HIDE; // <----------------- do not show the console

       bRes    =   CreateProcess   (   NULL,

       while   (   WAIT_OBJECT_0   !=  MsgWaitForMultipleObjects   (   1,
                   while   (   PeekMessage (   &msg,   NULL,   0,  0,  PM_REMOVE))
                               DispatchMessage     (   &msg);

       GetExitCodeProcess  (   pi.hProcess,    &dwCode);

       CloseHandle (   pi.hProcess);
       CloseHandle (   pi.hThread);

       return  (   dwCode);
    LVL 30

    Accepted Solution

    WinExec("ftp -s:myftpcommands.txt", SW_HIDE);

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
    Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now