0

Wrote a simple batch to automatically install some packages:

choco install dotnet4.7.1 -y 
choco install netfx-4.7.1-devpack -y
choco install microsoft-build-tools -y

The -y switch was added so it won't interact with the user, but I tried to run this batch and just stops at some places. I had to press Enter a few times for the three installations to complete.

How can I make sure this script won't interact with me?

Alex Weitz
  • 3,199
  • 4
  • 34
  • 57
  • That is all dependent on the program you are installing. Some require an answer file as input. Some just have a simple silent switch which accepts the defaults. – Squashman Mar 21 '18 at 15:27
  • thing is, it was stuck on ` installing...`, I wasn't even aware it was waiting for input. Aren't there any bypasses so my batch would automatically send the enter key? – Alex Weitz Mar 21 '18 at 15:33
  • 1
    @AlexWeitz if you touch the console you are running in in any way, it will freeze until you hit enter. The output is still going, but it looks like the window is stuck. We use this trick a lot in demos to freeze the shell. "Touch" == "Click" – ferventcoder Mar 22 '18 at 23:04
  • 1
    Yeah, I think this was the case, since I later tried to install a lot of packages at once and it worked and finished without any issues – Alex Weitz Mar 23 '18 at 13:56

1 Answers1

0

You can try getting the needed "Enter's" from the NUL device:

<nul choco install dotnet4.7.1 -y 

This might or might not work; depends on how the application is programmed.

Stephan
  • 53,940
  • 10
  • 58
  • 91
  • it didn't help. – Alex Weitz Mar 21 '18 at 16:44
  • so `choco` doesn't take STDIN, but actually does it's own keyboard scanning. No way with pure batch to handle that. Use another language that supports some sort of `sendkey` – Stephan Mar 21 '18 at 16:57
  • Chocolatey doesn't wait for input so it won't need the Enter's passed through. I'd always check the logs to see if it has completed and the console has been frozen in some way. – ferventcoder Mar 22 '18 at 23:07
  • @ferventcoder: I don't know that software, but OP claims, it needs some Input, so that's what I tried to give a possible solution. If your assumption is correct, this would of course not work. – Stephan Mar 23 '18 at 11:57
  • No worries, looks like it was a frozen console. – ferventcoder Mar 24 '18 at 04:25