@echo off :: index.cmd by Rafael Vuijk (aka Dark Fader) :: :: apache-style HTTP directory viewer :: CGI Windows command script :: Start with: http://server/scripts/cmd.exe?/E:ON /C index.cmd :: :: Features: :: directory links - browse directories :: file links - download (with or without IUSR_ access) :: date - click to delete file :: Wildcard - uses wildcard for directory listing :: Search - not implemented yet :: Base URL - if set, uses a base URL for downloading files (faster but no IUSR_ access). can be relative and usually '..' will do. :: Upload - not implemented yet :: :: History: :: v1.03 - base URL :: v1.02 - fixed mask so it can take more :: v1.01 - able to download/delete from any directory, wildcards :: v1.00 - able to view/download from current directory :: command/sessios parameters set BROWSEDIR=%~1 set COMMAND=%~2 set FILENAME=%~3 set MASK=%~4 set BASEURL=%~5 :: process parameters ::set SCRIPTDIR=%CD% ::for /F "usebackq" %%I in (`echo %CD:%SCRIPTDIR%^=%`) do set RELDIR=%%I set BROWSEDIR=%BROWSEDIR:/=\% cd /D "%BROWSEDIR%" set BROWSEDIR=%CD% if "%MASK%"=="" set MASK=* :: delete command if "%COMMAND%"=="DEL" del "%FILENAME%" 2> nul :: get command if "%COMMAND%"=="GET" ( echo Content-type: application/octet-stream echo Connection: Close for %%I in ("%FILENAME%") do echo Content-Length: %%~zI for %%I in ("%FILENAME%") do echo Last-Modified: %%~tI for %%I in ("%FILENAME%") do echo Content-Disposition: filename=%%~nxI echo. type "%FILENAME%" goto :EOF ) :: header echo Content-type: text/html echo. echo ^^^^Index of %CD%^ echo ^