Reputation: 133
I Made A Batch File Which Would Open In Notepad++ From The CURRENT DIRECTORY where the batch file is located(with run.. feature in notepad++), But I Want batch file to open on the folder where i have opened the file.
Example:
My Batch File Is Located In D:\Projects\Java\Executor Java.bat
I Have Opened A File Of .java Extension in D:\Java\Files
I Want to open at file location,i.e. D:\Java\Files
My batch file Looks like this:
@ECHO OFF
ECHO WELCOME TO EXECUTOR
ECHO -Garvit Joshi([email protected])
ECHO USER:%USERNAME%
cd /d "%~dp0"
:first
ECHO LOOKING FOR FILES IN:"%~dp0"
set /p "input=Enter The File You Want To Execute:"
ECHO ===============================
javac %input%.java
ECHO ===============================
set /p "input=Enter The Class You Want To Run:"
ECHO ===============================
ECHO OUTPUT:
ECHO ===============================
java %input%
ECHO ===============================
pause
ECHO =======================================================
ECHO *******************************************************
ECHO =======================================================
goto first
Upvotes: 0
Views: 181
Reputation: 780
You'll need to pass the path as a parameter from Notepad++ in the 'Run...' dialog, e.g:
cmd /c "D:\Projects\Java\ExecutorJava.bat $(CURRENT_DIRECTORY)"
..then have your batch file use the parameter with something like:
cd /d "%1"
(In this example, have removed the space from the "Executor Java.bat" filename for convenience)
Upvotes: 2