I am running a batch file, where I want to pass parameters from Textbox
Batch: test.bat
@echo off
set par1=%1
echo Parameter 1 is %par1%
mkdir %par1%
Java:
Process p = Runtime.getRuntime().exec("c:\\test.bat");
How to pass parameter to Test.bat file?
You can just add the parameter to the command line:
This will pass
xyzto the batch file.But
Runtime.getRuntime().exec(..)is not a good way to execute an external program. You should useProcessBuilderinstead.