1

I'm using maven as my build tool and I want to create a batch script that opens a cmd window in a given directory, runs my maven build command, doesn't exit on the build finishing AND allows me to just hit the up arrow and run the maven build again. My usecase would be running this script at the start of the day then being able to come back to it and executing a new build by just hitting the up arrow and enter.

Here's my current batch script, which does remain open after it runs the command, but it isn't saved to the cmd's history

cd /d  C:\source\project

cmd /k mvn -U clean install

1 Answers1

0

This code do what you want:

@if (@CodeSection == @Batch) @then

@echo off
cd /d  C:\source\project
start cmd 
CScript //nologo //E:JScript "%~F0" "mvn -U clean install{ENTER}"
goto :EOF

@end

WScript.CreateObject("WScript.Shell").SendKeys(WScript.Arguments(0));

Further details here, or here, or here, or... (look for "SendKeys")

Aacini
  • 65,180
  • 12
  • 72
  • 108