2

I am executing a batch file as a pre-build event. The batch file however is expecting user input to continue (i.e., "Type x to continue")

Is there a way to enter an 'x' followed by 'Enter' in the pre-build event so that the process continues.

Additionally, I have a second batch file that is run after the first. Will the pre-build process wait for the first to complete or will it try to execute the second batch file immediately after calling the first? If so can I add a wait or pause to the pre-build?

BrianKE
  • 4,035
  • 13
  • 65
  • 115
  • 2
    can you share code in batch file 1 , which becomes easy why it is waiting for a user input ? rather we can tweak that first to solve the issue . – prudviraj Nov 17 '15 at 15:20

1 Answers1

1

Use the call function with a new line and it will call the second batch file after the first batch file is called. How to: Specify Build Events

 call C:\MyFile.bat
 call C:\MyFile2.bat

You can pipe in user input characters using the | syntax

e.g.:

x is sent to the batch file along with the enter key.

 call echo x|C:\MyFile.bat 

Note: Pre-build events do not run if the project is up to date and no build is triggered

SoftwareCarpenter
  • 3,835
  • 3
  • 25
  • 37
  • I think you should use the pipe like `echo x|call C:\MyFile.bat`, because the command line `call echo x|C:\MyFile.bat` calls the `echo` command instead of the batch file... – aschipfl Nov 18 '15 at 01:45
  • @aschipfl it is taking the output of echo x and using it as input for the bat file . You have to use the call function because it is being used in a pre build event. I think putting echo in front will cause it to not execute correctly . I could be wrong but I know it works with the call first. Remember it is being called from pre build event. – SoftwareCarpenter Nov 18 '15 at 02:19