:: GET WINDOW TITLE :: The batch displays the window title :: WMIC must be present in the system. In some Windows Home editions is it missing. @ECHO OFF :: Set temp file name and random string SET TmpFile=%~DP0TMP%RANDOM%.txt SET RandomString=%RANDOM%%RANDOM%%RANDOM%%RANDOM% :: run WMI query to find ParentProcessID of process having RandomString in command line WMIC PROCESS WHERE "commandline LIKE '%%%RandomString%%%'" get parentprocessid > "%TmpFile%" :: retrieve PID from TmpFile; PID == current window PID FOR /F "tokens=1" %%A IN ('TYPE "%TmpFile%"') DO SET ParentPID=%%A :: Delete temporary file, it is no longer needed DEL "%TmpFile%" :: Run TASKLIST and filter output to current window PID. :: As only one record is displayed the "LIST" output format can be used for easy field name selection FOR /F "tokens=2,* delims= " %%A IN ('TASKLIST /V /FO "LIST" /FI "PID eq %ParentPID%"^|FIND "Window Title: "') DO SET WindowTitle=%%B :: Echo the title ECHO %WindowTitle%