@echo off
setlocal EnableDelayedExpansion
set "url=http://example.com/file.txt"
set "filename=file.txt"
echo Downloading %filename% from %url%...
powershell -command "(New-Object System.Net.WebClient).DownloadFile('%url%', '%filename%')"
if exist %filename% (
echo File downloaded successfully.
del %filename%
echo File deleted.
) else (
echo Error downloading file.
)