get current path in DOS-Batch

need to get the current path your batch file is executed in? Try this:

echo %~dp0%jre


get year in dos-batch

To get the year in format YYYY in a DOS-Batch check this out:


@echo off
set date=%date%
set year=%date:~6,4%

echo %year%


cheatsheet dos

Cheatsheat for DOS batches

Comment REM This is a comment in a DOS batch file
print ECHO Hello World!
Arguments %1 %2 %3
if IF (condition) (
REM Do stuff
) ELSE (
REM Do other stuff
)
for for /l %%x in (1, 1, 5) do ( REM Do stuff)
Exit EXIT
Get return code ECHO %errorlevel%