rem *** Author: T. Wittrock, RZ Uni Kiel ***

if "%WSUS_LOGFILE%"=="" set WSUS_LOGFILE=%SystemRoot%\ctupdate.log

if "%1"=="" goto NoParam
if "%2"=="" goto NoParam

if exist "%TEMP%\Update.txt" goto EoF
if not exist %2\nul goto EoF
dir /A:-D /B /OD %2\*%1*.* > "%TEMP%\Update.txt" 2>nul
if errorlevel 1 (
  if exist "%TEMP%\Update.txt" del "%TEMP%\Update.txt"
) else (
  for /F "usebackq" %%i in ("%TEMP%\Update.txt") do echo %2\%%i >> "%TEMP%\UpdatesToInstall.txt"
)
goto EoF

:NoParam
echo ERROR: Invalid parameter. Usage: %~n0 {kbid} {directory}
echo %DATE% %TIME% - Error: Invalid parameter. Usage: %~n0 {kbid} {directory} >> %WSUS_LOGFILE%
exit /b 1

:EoF
