I added a DOSKEY alias via batch script (script1.bat) and try to call it in another batch script. It doesn't work.
script1.bat:
set USER_SETTINGS=%DRIVE%\programme\settings.xml
DOSKEY mvn=mvn --settings %USER_SETTINGS% -X $*
script2.bat:
mvn clean install
When I call mvn clean install
from the console, it works. The debug output is forthcoming. When I call script2.bat from the same console, no debug output is coming.
Can anyone help?
If you show the doskey help via doskey /?
you get something like: "Recall and edit commands at the DOS prompt, and create macros". A Batch file is not the DOS prompt: the DOSKEY command works with keys pressed as input, like arrows or F7 keys.
For this reason, the next code should work:
script2.bat:
@if (@CodeSection == @Batch) @then
@echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
rem Send the keys with the DOSKEY macro name:
%SendKeys% "mvn clean install{ENTER}"
goto :EOF
@end
// JScript section
WshShell.SendKeys(WScript.CreateObject("WScript.Shell").Arguments(0));
Further details at Press Keyboard keys using a batch file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With