0

Is there a way to write a .bat file which sends all my inputs to a program running in background ?

Something like this ,

  1. c:\start.bat
  2. Opens a new prompt ,
  3. But whatever I type in new prompt should go to the default program running in the background (Don't know where to specify the default program , I don't want to show the program name each time I pass the arguments). I want to use something like this line ,

    <CUSTOM_PROMPT>"select data from tablex" , the string should go the "programX.bat" 
    

    instead of

    <CUSTOM_PROMPT>programX.bat "select data from tablex" 
    
srinannapa
  • 3,085
  • 8
  • 49
  • 66
  • This solution might give you some ideas: http://stackoverflow.com/questions/8192318/why-does-delayed-expansion-fail-when-inside-a-piped-block-of-code#8194279 – David Apr 10 '15 at 20:11

1 Answers1

0

I am afraid your question is not clear; there are many details that needs clarification. However, the Batch file below may give a starting point of discussion for both of us:

@echo off
setlocal

if "%~1" equ "goto" goto %2

cls
echo I am the user-interface program 
echo Enter "exit" (with no quotes) to end
echo/

"%~F0" goto getInput | "%~F0" goto background > background.txt

echo/
echo The user-interface program ends
echo/
echo This is the input captured by background program:
echo/
type background.txt
goto :EOF


:getInput
set /P "input=<CUSTOM_PROMPT>: " > CON
echo %input%
if /I "%input%" neq "exit" goto getInput
goto :EOF


:background
set /P input=
if /I "%input%" equ "exit" goto :EOF
echo Input received at %time%:
echo %input%
echo/
goto background
Aacini
  • 65,180
  • 12
  • 72
  • 108