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. a problem on WinExec

a problem on WinExec

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 2 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.
  • O Offline
    O Offline
    olinn
    wrote on last edited by
    #1

    I can use this command line "exefilename.exe -? >>a.txt" in Windows command prompt to store the parameter information into a.txt. But when I use WinExec to execute this command in my program, it doesn't work. neither does ShellExecute. The only thing it does is displaying the parameter info in the command prompt terminal (I can see the prompt flashing). Thank you to help me!

    C 1 Reply Last reply
    0
    • O olinn

      I can use this command line "exefilename.exe -? >>a.txt" in Windows command prompt to store the parameter information into a.txt. But when I use WinExec to execute this command in my program, it doesn't work. neither does ShellExecute. The only thing it does is displaying the parameter info in the command prompt terminal (I can see the prompt flashing). Thank you to help me!

      C Offline
      C Offline
      Chris Richardson
      wrote on last edited by
      #2

      Well, the program itself isn't the one doing the redirecting, it's the "cmd" (NT bases systems) or "command" (95 bases boxes) program that does the redirecting. So, if you want to do it, you can do it like this:

      // NOTE: not very safe code. Also, it will only work on NT/2K/XP (since I used cmd.exe).
      TCHAR a_szCommandLine[512] = {0};
      _stprintf( a_szCommandLine, _T("cmd.exe /c \"exefilename.exe -? > a.txt\"") );
      WinExec( a_szCommandLine, SW_HIDE );

      Chris Richardson
      Terrain Software

      O 1 Reply Last reply
      0
      • C Chris Richardson

        Well, the program itself isn't the one doing the redirecting, it's the "cmd" (NT bases systems) or "command" (95 bases boxes) program that does the redirecting. So, if you want to do it, you can do it like this:

        // NOTE: not very safe code. Also, it will only work on NT/2K/XP (since I used cmd.exe).
        TCHAR a_szCommandLine[512] = {0};
        _stprintf( a_szCommandLine, _T("cmd.exe /c \"exefilename.exe -? > a.txt\"") );
        WinExec( a_szCommandLine, SW_HIDE );

        Chris Richardson
        Terrain Software

        O Offline
        O Offline
        olinn
        wrote on last edited by
        #3

        It works! Thanks a lot.

        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