Search code examples
c#visual-studiobatch-filepre-build-event

User entered text during pre-build event


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?


Solution

  • 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