Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. open application in hidden mode

open application in hidden mode

Scheduled Pinned Locked Moved C / C++ / MFC
question
11 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J JM2251

    hi, I am running an application with ShellExecute() but not able to run in hidden mode ShellExecute(NULL,_T("open"),_T("myapp.exe"),szCommandLineParameter,szTargetDirectoryPath,SW_HIDE); SW_HIDE - Hide command line . What is wrong?

    _ Offline
    _ Offline
    _Superman_
    wrote on last edited by
    #2

    Is it a cosole application? Try using CreateProcess instead with STARTF_USESHOWWINDOW in the dwFlags member of STARTUPINFO and SW_HIDE in its wShowWindow member.

    «_Superman_» I love work. It gives me something to do between weekends.
    Microsoft MVP (Visual C++)

    J 1 Reply Last reply
    0
    • J JM2251

      hi, I am running an application with ShellExecute() but not able to run in hidden mode ShellExecute(NULL,_T("open"),_T("myapp.exe"),szCommandLineParameter,szTargetDirectoryPath,SW_HIDE); SW_HIDE - Hide command line . What is wrong?

      R Offline
      R Offline
      R jeev K R
      wrote on last edited by
      #3

      What type of exe you are using...?

      J 1 Reply Last reply
      0
      • R R jeev K R

        What type of exe you are using...?

        J Offline
        J Offline
        JM2251
        wrote on last edited by
        #4

        command line exe

        R 1 Reply Last reply
        0
        • _ _Superman_

          Is it a cosole application? Try using CreateProcess instead with STARTF_USESHOWWINDOW in the dwFlags member of STARTUPINFO and SW_HIDE in its wShowWindow member.

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          J Offline
          J Offline
          JM2251
          wrote on last edited by
          #5

          yes, this is console application

          _ 1 Reply Last reply
          0
          • J JM2251

            yes, this is console application

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #6

            In that case, the solution that I gave using CreateProcess will work.

            «_Superman_» I love work. It gives me something to do between weekends.
            Microsoft MVP (Visual C++)

            J 1 Reply Last reply
            0
            • _ _Superman_

              In that case, the solution that I gave using CreateProcess will work.

              «_Superman_» I love work. It gives me something to do between weekends.
              Microsoft MVP (Visual C++)

              J Offline
              J Offline
              JM2251
              wrote on last edited by
              #7

              yes I tired but same result as ShellExecute. :(

              _ 1 Reply Last reply
              0
              • J JM2251

                yes I tired but same result as ShellExecute. :(

                _ Offline
                _ Offline
                _Superman_
                wrote on last edited by
                #8

                I tried this again and it works perfectly.

                wchar_t szCommand[] = L"C:\\Windows\\System32\\Cmd.exe";

                STARTUPINFO si;
                ::ZeroMemory(&si, sizeof(STARTUPINFO));
                si.cb = sizeof(STARTUPINFO);
                si.dwFlags = STARTF_USESHOWWINDOW;
                si.wShowWindow = SW_HIDE;

                PROCESS_INFORMATION pi;

                ::CreateProcess(0, szCommand, 0, 0, 0, 0, 0, 0, &si, &pi);

                «_Superman_» I love work. It gives me something to do between weekends.
                Microsoft MVP (Visual C++)

                J 1 Reply Last reply
                0
                • _ _Superman_

                  I tried this again and it works perfectly.

                  wchar_t szCommand[] = L"C:\\Windows\\System32\\Cmd.exe";

                  STARTUPINFO si;
                  ::ZeroMemory(&si, sizeof(STARTUPINFO));
                  si.cb = sizeof(STARTUPINFO);
                  si.dwFlags = STARTF_USESHOWWINDOW;
                  si.wShowWindow = SW_HIDE;

                  PROCESS_INFORMATION pi;

                  ::CreateProcess(0, szCommand, 0, 0, 0, 0, 0, 0, &si, &pi);

                  «_Superman_» I love work. It gives me something to do between weekends.
                  Microsoft MVP (Visual C++)

                  J Offline
                  J Offline
                  JM2251
                  wrote on last edited by
                  #9

                  yes this will hide the command prompt but what about the other application which will launch through command prompt.

                  wchar_t szCommand[] = L"-m -l";//command line parameter for application

                  STARTUPINFO si;
                  ::ZeroMemory(&si, sizeof(STARTUPINFO));
                  si.cb = sizeof(STARTUPINFO);
                  si.dwFlags = STARTF_USESHOWWINDOW;
                  si.wShowWindow = SW_HIDE;

                  PROCESS_INFORMATION pi;

                  ::CreateProcess(_T("myapp.exe"), szCommand, 0, 0, 0, 0, 0, 0, &si, &pi);

                  R 1 Reply Last reply
                  0
                  • J JM2251

                    command line exe

                    R Offline
                    R Offline
                    R jeev K R
                    wrote on last edited by
                    #10

                    First try with SW_SHOWNORMAL mode. if it is working fine then try with SW_HIDE. If it is also not working then check the exe path and command line arguments. Is it running in normal mode when you using SW_HIDE argument...?

                    1 Reply Last reply
                    0
                    • J JM2251

                      yes this will hide the command prompt but what about the other application which will launch through command prompt.

                      wchar_t szCommand[] = L"-m -l";//command line parameter for application

                      STARTUPINFO si;
                      ::ZeroMemory(&si, sizeof(STARTUPINFO));
                      si.cb = sizeof(STARTUPINFO);
                      si.dwFlags = STARTF_USESHOWWINDOW;
                      si.wShowWindow = SW_HIDE;

                      PROCESS_INFORMATION pi;

                      ::CreateProcess(_T("myapp.exe"), szCommand, 0, 0, 0, 0, 0, 0, &si, &pi);

                      R Offline
                      R Offline
                      Rozis
                      wrote on last edited by
                      #11

                      JM2251 wrote:

                      yes this will hide the command prompt but what about the other application which will launch through command prompt.

                      You're correct: Cmd is hidden but the app it's executing not. Some solutions: - create a shortcut to the exe and run that one. In the shortcut you can set options to hide it. - If it is a console app you could route the display output to a NULL device (example: Dir > null). See createprocess options. Hope this helps

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups