Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6712483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:15:54+00:00 2026-05-26T08:15:54+00:00

I am trying to create a pipe between a command line shell and my

  • 0

I am trying to create a pipe between a command line shell and my application.

This is the code I have so far:
http://pastebin.com/uupd4aXi

What I am trying to do is write “whoami” to stdin and get a return equivalent to that command.
If I comment out the writeinput function, readoutput successfully prints the standard cmd printout. However if I don’t, writeinput gets stuck at an infinite loop at:

for (;;) 
    { 

        bSuccess = WriteFile(hSTD_IN_WRITE, chBuf, sizeof(chBuf), &dwWritten, NULL);
        if ( ! bSuccess ) break; 
    } 

If i remove the if statement and manually cause a break on the loop, I am still only getting the cmd printout message but not the respone to my command “whoami”.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:15:54+00:00Added an answer on May 26, 2026 at 8:15 am

    You are running into the trap of redirecting both stdin and stout but processing them serially.

    If all you want to do is run the whoami program and capture the output, then you don’t need cmd.exe and try to pump whoami.exe as its input. Just run whoami.exe directly and capture its output.

    EDIT: updated link to the article:
    https://devblogs.microsoft.com/oldnewthing/20110707-00/?p=10223

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a script/application which accepts command line arguments when run. Of
I trying to create a pipe using C#. The code is quite simple but
I am trying to create a function which takes a shell command as an
I'm trying to create arrays from strings that have pipe (|) as delimiters and
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to create a small monitor application that displays current internet usage as percentage
I have been trying to get up to speed on Named Pipes this week.
I am trying to write a GUI program for a command line program in
I'm trying create a RCP Application with Eclipse, but I can't get past the
I'm trying to create a two-way communication channel between two programs (one in Python

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.