none
Auto answer Y for batch files. RRS feed

  • Question

  • Hi,

    I am writing a batch file which runs a command prompt to execute an application. - the command line needs a confirmation Y or N after the line is run - how can I automate the answer to be Y via a batch file?

    I need to input Y for Yes two times one after other. is there any way i can automate it so that it will automatically take Y as input and complete the required task.

    Thanks,

    Kiran Raj

    Tuesday, February 4, 2014 10:40 AM

Answers

All replies

  • You can echo Y into the command via the pipe line

    For example

    Echo Y | Del *.*


    • Edited by Newbie Jones Tuesday, February 4, 2014 11:58 AM extra info
    Tuesday, February 4, 2014 11:57 AM
  • Hi ,

    i already tried it. Echo Y | (my script)

    But it does not work. Can you tell me whats the use of Del*.*

    Thanks in advance,

    Kiran Raj

    Tuesday, February 4, 2014 1:14 PM
  • del *.* was just an example of a command that sometimes needs confirmation prompts. However, if you were using del, it would be better to just use its "/Q" parameter (which suppresses confirmation prompts.) Whatever executable you're using may have a similar option.  What command is prompting you to press Y?

    Tuesday, February 4, 2014 1:22 PM
  • Hi ,

    i already tried it. Echo Y | (my script)

    But it does not work. Can you tell me whats the use of Del*.*

    Thanks in advance,

    Kiran Raj

    The "Del" (delete) command was just Newbie Jones' example for the technique to pipe "y" into a command. It is not relevant for you.

    If your applications do not process piped-in letters then there is nothing you can do other than asking the supplier of the applications to modify them for you. But perhaps the prompt is generated by your own script, not an application. Your post is somewhat ambiguous in this respect - please clarify!

    Theoretically it is possible for a script to issue keystrokes such as "Y". In practice the technique is useless because it is not possible to direct the keystroke reliably to a specific application or pop-up box.


    Tuesday, February 4, 2014 1:24 PM
  • Hi 

    I'm trying to gererate EMC Grab report,

    Here is the command which i use,

    emcgrab.exe -host (server name) -user XXXX -password XXXXXXX -vmsupport.

    the moment i run this system will ask for input for accepting license.

    I just need to skip this by accepting Yes.

    Please help.

    Thanks,

    Kiran Raj

    Tuesday, February 4, 2014 1:54 PM
  • According to ftp://ftp.emc.com/pub/emcgrab/ESX/Readme_EMCGrab_ESX_vSphere_v1_3_1.txt , it looks like you just need to add the -autoexec and -legal switches to your call to emcgrab.exe:

    emcgrab.exe -host (server name) -user XXXX -password XXXXXXX -vmsupport -autoexec -legal

    • Marked as answer by Kiran Raj Tuesday, February 4, 2014 9:34 PM
    Tuesday, February 4, 2014 2:00 PM
  • Thanks David,

    i was looking for this exactly. it ran successfully.

    Tuesday, February 4, 2014 9:35 PM