net use * /del /yes NET USE X: \\10.29.48.12\shares\Test password /user:DOMAIN1\account set AutoPath=X:\ %AutoPath:~0,2% pushd %AutoPath% cd /d %AutoPath% rem delete reports generated 7 days ago forfiles /p %AutoPath% /s /m *.* /d -7 /c "cmd /c del /f @path">nul 2>nul ping 127.0.0.1 -n 15 > nul for /f "tokens=*" %%a in ('dir /b /ad /s^|sort /r') do rd "%%a" 2>nul ping 127.0.0.1 -n 15 > nul exit 0