Open file with batch file, then use file in java class -


i need open file batch file this:

(right click file.txt) > "open with" file.bat

then need location of file.txt , set variable path this:

set path = <file.txt path> java test.class path  

how can set path location of file.txt without hardcoding in path (i not know filename or location)

squashman has given in comment every information required batch file coding task.

first, don't add spaces around equal sign on assigning string value environment variable. see answer on why no string output 'echo %var%' after using 'set var = text' on command line? detailed explanation.

second, don't use names environment variables predefined windows path extremely important predefined environment variable. open command prompt window , run set output environment variables predefined current user account. details variables can found in wikipedia article windows environment variables. using path environment variable name results here in error message on next line because java.* file extension defined in environment variable pathext can't found in current directory or directory defined in environment variable path.

third, windows explorer passes file(s) selected started process on using send to full file name (path + file name + file extension) enclosed in double quotes. run in command prompt window call /? output on how reference argument string of batch file.

so might need in batch file is:

java.exe test.class "%~dp1" 

if want see how batch file started windows explorer, put @ top of batch file following 2 commands:

@echo %0 %* @pause 

the first line output batch file shows how windows explorer started batch file via command interpreter cmd.exe.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -