有没有办法编写.bat文件,将所有输入发送到后台运行的程序?
像这样,
但是我在新提示中键入的内容应该转到后台运行的默认程序(不知道在哪里指定默认程序,我不想每个都显示程序名称我通过论证的时间)。我想使用类似这一行的东西,
<CUSTOM_PROMPT>"select data from tablex" , the string should go the "programX.bat"
而不是
<CUSTOM_PROMPT>programX.bat "select data from tablex"
答案 0 :(得分:0)
我担心你的问题不明确;有许多细节需要澄清。但是,下面的批处理文件可以为我们双方提供讨论的起点:
@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