How can i suppress a user prompt while running a batch file in windows 2000 machine??
thanks in advance.
Abhishek

Dani AI

Generated

As noted, the correct approach depends on the program being run. Common, reliable patterns for Windows 2000 batch automation are: use the program's unattended/quiet flags when available; send canned answers via a pipe or a file if the program reads stdin; or use a small automation script (AutoIt, VBScript) when prompts come from a GUI or the program reads the console device.

Practical patterns (drop into a .bat):

xcopy "C:\src\*" "D:\dst\" /Y
rd /S /Q "C:\temp\old"
msiexec /i "setup.msi" /qn

echo Y | installer.exe
type answers.txt | program.exe

program.exe > run.log 2>&1
if %ERRORLEVEL% NEQ 0 echo FAILED: %ERRORLEVEL% >> run.log

Notes and troubleshooting: many command-line tools support switches like /Y, /Q, /S or vendor-specific /silent options — prefer those first because they are robust. Piping or feeding an answers file works, but some programs read from the console device (CON) and will ignore stdin; in those cases use an automation tool (AutoIt or a script that drives the GUI). Capture both stdout and stderr (2>&1) and check %ERRORLEVEL% after each step to detect failures. Test scripts on a non-production copy and log runs so unexpected prompts can be identified and fixed.

Recommended Answers

All 3 Replies

It depends on what you are doing.

Some commands have a /b or /n switch to tell them they are being run from a batch file (and to suppress prompts.)

Another way is to have input and output redirection. But the input file must have all of the correct responses in the correct order (and the batch file can go horribly wrong if an unexpected error prompt appears. Put the redirection in the command line that starts the batch file, or in the batch file line which starts the command.

< redirects input, > redirects output, >> redirects error messages. There must be no space between the redirection sysmbol and the file.

dothis.bat <promansr.txt >digester.txt

I didnt get a clear cut picture. Can u plz explain it with an example.But the >> is a command for appending.
Thanks in advance,
Abhishek.

You are right, I was thinking of the OS-9 similar redirections. DOS uses >> for append.

In my example, dothis.bat is the batch file.

promansr.txt is a text file full of the expected responses to prompts, one response per line.


e.g. (I put the question over to the right. it is not part of the file)

y        (are you sure?)
n        (send to printer?)
          (Press ENTER to continue.)
y        (Replace the file? y/n/c=cancel)

digester.txt takes all of the output and "digests" it. You need to remove the file between runs of the batch file. You can do this by calling another batch file which deletes the file (and the two batch files could delete each other's files).

ECHO OFF

this command as the first line of a batch file also removes a lot of queries.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.