If your script requires that you run the task list utility, you must choose the proper executable for your operating system.

Windows NT and Windows 2000 uses Tlist.exe, while Windows XP, Windows Server 2003, and newer operating systems use TaskList.exe.

I have scripted TskLst.bat to return the proper executable. The syntax for using TskLst.bat is:

call tsklst ProgramName

where ProgramName is a call directed environment variable that will be set to tlist.exe or tasklist.exe.

To run the task list, you would use %ProgramName% instead of the actual program name.

TskLst.bat contains:

@echo off                              if \{%1\}==\{\} @echo Syntax: call tsklst ProgramName&goto :EOF                              setlocal                              set tasklist=tasklist.exe                              for /f "Tokens=2,3 Delims=\[." %%v in ('ver') do set version=%%v.%%w                              set version=%version:version =%                              set version=%version:00=0%                              if "%version%" LSS "5.1" set tasklist=tlist.exe                              endlocal&set %1=%tasklist%