1.

Solve : Batch asking question to add value to jar parameter?

Answer»

hello all

I don't know where to begin with this... I'd like to have a BATCH asking the user to input data (text), then this data would LATER be used as a parameter for a java file...

Here's my thoughts:
Code: [Select]echo off
path=d:\AUXID\
echo input the CipherValue
echo.
pause
set input=
set /p input=%1
"C:\Program Files (x86)\Java\jre8\bin\java.exe" -jar SeedDecrypt.jar Ciphervalue %1 hex-key 1FF7738D8A8C5040DC68B9CB4E8DE2A2 >>d:\AUXID\SeedDecrypt.txt
echo see file d:\AUXID\SeedDecrypt.txt for infos.
echo.
pause
exit

My questions are :
1.  is my %1 input correct
2. dough I got a java error
Code: [Select]Exception in thread "main" org.apache.commons.codec.DecoderException: Odd NUMBER of characters.
        at org.apache.commons.codec.binary.Hex.decodeHex(Hex.java:82)
        at DecryptionText.main(DecryptionText.java:28)
My SeedDecrypt.txt file has a size of 0KB each time.

can someone help me on this%1 would be a command line argument.
Meaning you would start the batch file from the command prompt like this.
Code: [Select]C:\mybatchfile.bat sometext
If you want to ask for input you are partially doing it correctly by USING the SET /P but you never use the INPUT variable in your JAVA command.
Code: [Select]Set /P input=input the CipherValue:
"C:\Program Files (x86)\Java\jre8\bin\java.exe" -jar SeedDecrypt.jar Ciphervalue %input% hex-key 1FF7738D8A8C5040DC68B9CB4E8DE2A2 >>d:\AUXID\SeedDecrypt.txt Quote from: metal_man77 on November 05, 2014, 01:47:24 PM

Code: [Select]echo off
path=d:\AUXID\

Additionally, the path variable is a system variable and shouldn't be used as a general purpose variable name,
and when you are adding a folder to the path then you can use something like this Code: [Select]set "path=%path%;c:\new\folder" Quote from: foxidrive on November 06, 2014, 04:15:06 AM
Additionally, the path variable is a system variable and shouldn't be used as a general purpose variable name,
and when you are adding a folder to the path then you can use something like this Code: [Select]set "path=%path%;c:\new\folder"
Good catch.  I was so focused on the code errors I must have glazed over that.  Thanks !
now it looks like this :
Code: [Select]echo off
path=%path%;d:\AUXID\
set input=
set /p input=input the CipherValue
"C:\Program Files (x86)\Java\jre8\bin\java.exe" -jar d:\AUXID\SeedDecrypt.jar Ciphervalue %input% hex-key 1FF7738D8A8C5040DC68B9CB4E8DE2A2 >>d:\AUXID\SeedDecrypt.txt
echo see file d:\AUXID\SeedDecrypt.txt for infos.
echo.
pause
exit

I still have the Java error, but I GUESS it's because I input random $hit.
and still my txt file is at 0KB.Not sure why you are screwing around with path variable.  It is not needed in your script at all.

We would have no idea how to debug your Java program. But I am pretty sure you batch code is rock solid now.Thanks for the Help !
Took out the path variable like you said.
Now I just have to figure out the java error.

Thanks a lot !


Discussion

No Comment Found