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. Hide the cmd window using createprocess function

Hide the cmd window using createprocess function

Scheduled Pinned Locked Moved C / C++ / MFC
9 Posts 5 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.
  • R Offline
    R Offline
    raj1576
    wrote on last edited by
    #1

    I want to Hide the my command window using createprocess i m using this like but not able to hide PROCESS_INFORMATION pInfo; STARTUPINFOA sInfo; DWORD exitCode; sInfo.cb = sizeof(STARTUPINFOA); sInfo.lpReserved = NULL; sInfo.lpReserved2 = NULL; sInfo.cbReserved2 = 0; sInfo.lpDesktop = NULL; sInfo.lpTitle = NULL; sInfo.dwFlags = 0; sInfo.dwX = 0; sInfo.dwY = 0; sInfo.dwFillAttribute = 0; sInfo.wShowWindow = SW_HIDE; memset (&sInfo, 0, sizeof(sInfo)); sInfo.cb = sizeof(sInfo); bool type = CreateProcess(NULL, cmdpath, NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pInfo);

    0 H K K 4 Replies Last reply
    0
    • R raj1576

      I want to Hide the my command window using createprocess i m using this like but not able to hide PROCESS_INFORMATION pInfo; STARTUPINFOA sInfo; DWORD exitCode; sInfo.cb = sizeof(STARTUPINFOA); sInfo.lpReserved = NULL; sInfo.lpReserved2 = NULL; sInfo.cbReserved2 = 0; sInfo.lpDesktop = NULL; sInfo.lpTitle = NULL; sInfo.dwFlags = 0; sInfo.dwX = 0; sInfo.dwY = 0; sInfo.dwFillAttribute = 0; sInfo.wShowWindow = SW_HIDE; memset (&sInfo, 0, sizeof(sInfo)); sInfo.cb = sizeof(sInfo); bool type = CreateProcess(NULL, cmdpath, NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pInfo);

      0 Offline
      0 Offline
      0x3c0
      wrote on last edited by
      #2

      I'm a little rusty, but doesn't that memset completely clear the STARTUPINFOA structure?

      R 1 Reply Last reply
      0
      • 0 0x3c0

        I'm a little rusty, but doesn't that memset completely clear the STARTUPINFOA structure?

        R Offline
        R Offline
        raj1576
        wrote on last edited by
        #3

        now i remove //memset (&sInfo, 0, sizeof(sInfo)); // sInfo.cb = sizeof(sInfo); but it is not also work........

        0 1 Reply Last reply
        0
        • R raj1576

          I want to Hide the my command window using createprocess i m using this like but not able to hide PROCESS_INFORMATION pInfo; STARTUPINFOA sInfo; DWORD exitCode; sInfo.cb = sizeof(STARTUPINFOA); sInfo.lpReserved = NULL; sInfo.lpReserved2 = NULL; sInfo.cbReserved2 = 0; sInfo.lpDesktop = NULL; sInfo.lpTitle = NULL; sInfo.dwFlags = 0; sInfo.dwX = 0; sInfo.dwY = 0; sInfo.dwFillAttribute = 0; sInfo.wShowWindow = SW_HIDE; memset (&sInfo, 0, sizeof(sInfo)); sInfo.cb = sizeof(sInfo); bool type = CreateProcess(NULL, cmdpath, NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pInfo);

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Is this your command window or cmd if its cmd you can use of cmd/h.

          Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

          R 1 Reply Last reply
          0
          • H Hamid Taebi

            Is this your command window or cmd if its cmd you can use of cmd/h.

            Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

            R Offline
            R Offline
            raj1576
            wrote on last edited by
            #5

            It is not cmd window this is my copymovie.exe which i run through createprocess in my mfc application

            H 1 Reply Last reply
            0
            • R raj1576

              It is not cmd window this is my copymovie.exe which i run through createprocess in my mfc application

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              Of course you have a way you can use of FindWindow for get hwnd to your window and then use of **::**ShowWindow(hwnd,SW_HIDE);

              Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

              1 Reply Last reply
              0
              • R raj1576

                I want to Hide the my command window using createprocess i m using this like but not able to hide PROCESS_INFORMATION pInfo; STARTUPINFOA sInfo; DWORD exitCode; sInfo.cb = sizeof(STARTUPINFOA); sInfo.lpReserved = NULL; sInfo.lpReserved2 = NULL; sInfo.cbReserved2 = 0; sInfo.lpDesktop = NULL; sInfo.lpTitle = NULL; sInfo.dwFlags = 0; sInfo.dwX = 0; sInfo.dwY = 0; sInfo.dwFillAttribute = 0; sInfo.wShowWindow = SW_HIDE; memset (&sInfo, 0, sizeof(sInfo)); sInfo.cb = sizeof(sInfo); bool type = CreateProcess(NULL, cmdpath, NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pInfo);

                K Offline
                K Offline
                KarstenK
                wrote on last edited by
                #7

                You are shure that the windows isnt opened from the cmdpath?

                Greetings from Germany

                1 Reply Last reply
                0
                • R raj1576

                  now i remove //memset (&sInfo, 0, sizeof(sInfo)); // sInfo.cb = sizeof(sInfo); but it is not also work........

                  0 Offline
                  0 Offline
                  0x3c0
                  wrote on last edited by
                  #8

                  Why have you commented out the line which holds the size of sInfo?

                  1 Reply Last reply
                  0
                  • R raj1576

                    I want to Hide the my command window using createprocess i m using this like but not able to hide PROCESS_INFORMATION pInfo; STARTUPINFOA sInfo; DWORD exitCode; sInfo.cb = sizeof(STARTUPINFOA); sInfo.lpReserved = NULL; sInfo.lpReserved2 = NULL; sInfo.cbReserved2 = 0; sInfo.lpDesktop = NULL; sInfo.lpTitle = NULL; sInfo.dwFlags = 0; sInfo.dwX = 0; sInfo.dwY = 0; sInfo.dwFillAttribute = 0; sInfo.wShowWindow = SW_HIDE; memset (&sInfo, 0, sizeof(sInfo)); sInfo.cb = sizeof(sInfo); bool type = CreateProcess(NULL, cmdpath, NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pInfo);

                    K Offline
                    K Offline
                    KEL3
                    wrote on last edited by
                    #9

                    Your problem is in the Flags: sInfo.dwFlags = STARTF_USESHOWWINDOW;

                    		PROCESS\_INFORMATION pInfo;
                    		STARTUPINFOA sInfo;
                    		sInfo.cb = sizeof(STARTUPINFOA);
                    		sInfo.lpReserved = NULL;
                    		sInfo.lpReserved2 = NULL;
                    		sInfo.cbReserved2 = 0;
                    		sInfo.lpDesktop = NULL;
                    		sInfo.lpTitle = NULL;
                    		sInfo.dwFlags = STARTF\_USESHOWWINDOW;
                    		sInfo.dwX = 0;
                    		sInfo.dwY = 0;
                    		sInfo.dwFillAttribute = 0;
                    		sInfo.wShowWindow = SW\_HIDE;
                    
                    		BOOL ret = ::CreateProcess(m\_PathToExe, lpExePlusArgs, NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pInfo);
                    
                    		if(ret)
                    		{
                    			// Wait until application has terminated
                    			WaitForSingleObject(pInfo.hProcess, INFINITE);
                    
                    			// Close process and thread handles
                    			::CloseHandle(pInfo.hThread);
                    			::CloseHandle(pInfo.hProcess);
                    		}
                    

                    Read MSDN carefully and with patience.

                    kostas KEL

                    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