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 294793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:23:58+00:00 2026-05-12T06:23:58+00:00

I wanna build a console app that may stop and prompt for some input,

  • 0

I wanna build a console app that may stop and prompt for some input, under some conditions. But I want to prompt only if input will be available.

Is there a way to know if Stdin is connected to anything?

I think powershell does this, and I’d like to do something similar. Powershell detects when it is run interactively, and prompts when that is true. I think it is also possible to force powershell into non-interactive mode. (Correct me if I am wrong)

I guess I’m thinking there are several possibilities, including but not limited to:

  • the program is running interactively in a cmd.exe prompt. In this case, prompt for input.
  • the program is running within a script, and something haas been piped to stdin. In this case, no prompt.
  • the program is running within a script, which is running in a cmd.exe prompt. In which case, prompt.
  • the program is running from within another program, and nothing has been piped to stdin. In this case, no prompt.

Is it possible for a console app to distinguish between these situations and modify behavior accordingly?

  • 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-12T06:23:58+00:00Added an answer on May 12, 2026 at 6:23 am

    Check out the GetStdHandle API. Calling GetStdHandle(STD_INPUT_HANDLE) will return NULL if there is no associated stdin for the application.

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

Sidebar

Related Questions

I wanna stop the reading of my text input file when the word synonyms
I wanna learn how to build a p2p application in python that conforms to
I wanna build a Win32 app of Client/Server (or 3-tier) type with follow features:
I wanna build a client server iphone app and for this i need to
I wanna build one app into 2 version, one paid, one free, and I
I wanna build a TCP/IP server that will be used by up to 100
i've built my first wpf application, nothing fancy, but i wanna make it look
I wanna do something like the safari app when fill a form, so when
i wanna add a service behavior(or anything u'll suggest) that will automatically insert the
I'm somewhat familiar with WCF in that I can build Web Services in VS.Net

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.