Search code examples
batch-filecommand-line-arguments

How do I pass two 'echo n' responses to the same command in a batch file


I need to run the following batch file and pass "N" twice. I can figure out how to pass it once, but twice I just can't figure out:

@ECHO OFF

Regedt32 /s registrychanges.reg
echo n | gpupdate /force /sync
shutdown /r /f /t 0

The gpupdate /force /sync requires "N" twice. Even if I do echo n | echo n | gpupdate /force /sync it just hangs at the prompt for the second n.

Is there actually a way to pass two echo responses in a batch file for the same command?

Thanks!


Solution

  • Create a code block and pipe to the command.

    (
    echo n
    echo n
    )|gpupdate /force /sync