Page 1 of 1
Need help w/ Recycler.bat
Posted: 14 Jul 2010 01:28
by aseventhmindset
The function of the batch file is to delete all files that are selected and dropped over it as an argument. All of the files are deleted, but the VBScript message does not appear.
Code: Select all
@echo off
Title Recycler
set killcount=0
set deathcount=0
:lvl1
if exist %1 (del %1) else goto :results
if exist %1 (goto :question) else shift
set /a killcount=%killcount%+1
goto :lvl1
:question
set /p question=Some file could not be deleted. Do you wish to start exterminator mode? Y/N:
if /I %question%==y (goto :exterminate) else goto :results
:exterminate
tskill explorer
ping -w 1000 -n 1 1.1.1.1>nul
:lvl2
if not exist %1 start explorer & goto :results
del %1
if exist %1 (set /a deathcount=%deathcount%+1) else set /a killcount=%killcount%+1
shift & goto :lvl2
:results
if not exist "%temp%\results.vbs" echo msgbox"%killcount% files have been deleted. %deathcount% files could not be deleted.",16,"Recycler" > %temp%\results.vbs
start %temp%\results.vbs
exit
Re: Need help w/ Recycler.bat
Posted: 14 Jul 2010 02:37
by alan_b
I would expect the script to EXIT and possibly close the DOS Window after the Start but long before VBS got going.
A more suitable command could be
start /WAIT %temp%\results.vbs
If that fails look at options shown by
START /?
You probably have two different engines to process a *.vbs,
and perhaps you are using the default engine which does not meet your needs.
Alan
Re: Need help w/ Recycler.bat
Posted: 14 Jul 2010 04:46
by aGerman
aseventhmindset
Your problem is in this line:
Code: Select all
if not exist "%temp%\results.vbs" echo msgbox"%killcount% files have been deleted. %deathcount% files could not be deleted.",16,"Recycler" > %temp%\results.vbs
If the vbs file exists it will never change. Remove
if not exist "%temp%\results.vbs" , because you have to write a new vbs file each time.
Regards
aGerman
Re: Need help w/ Recycler.bat
Posted: 14 Jul 2010 11:03
by avery_larry
Also, since %temp% could include spaces:
start "" "%temp%\results.vbs"
Re: Need help w/ Recycler.bat
Posted: 14 Jul 2010 15:07
by aseventhmindset
The batch file continues to have the same response even after the changes. I am running XP. Please test this batch on your computer, see what results, and message me back if you find a solution.
Code: Select all
@echo off
Title Recycler
set killcount=0
set deathcount=0
:lvl1
if exist %1 (
del %1
) else (
goto :results
)
if exist %1 (
goto :question
) else (
shift
)
set /a killcount = %killcount% + 1
goto :lvl1
:question
set /p question=Some file could not be deleted. Do you wish to start exterminator mode? Y/N:
if /I %question%==y (
goto :exterminate
) else (
goto :results
)
:exterminate
tskill explorer
ping -w 1000 -n 1 1.1.1.1>nul
:lvl2
if not exist %1 start explorer & goto :results
del %1
if exist %1 (
set /a deathcount=%deathcount% + 1
) else (
set /a killcount=%killcount% + 1
)
shift
goto :lvl2
:results
echo msgbox"%killcount% files have been deleted. %deathcount% files could not be deleted.",16,"Recycler" > "%temp%\results.vbs"
start /wait "" "%temp%\results.vbs"
pause>nul
exit
Re: Need help w/ Recycler.bat
Posted: 14 Jul 2010 16:02
by aGerman
You could try it this way:
Code: Select all
@echo off
Title Recycler
set killcount=0
set deathcount=0
:lvl1
if exist "%~1" (
del "%~1"
) else (
goto :results
)
if exist "%~1" (
goto :question
) else (
shift
)
set /a killcount+=1
goto :lvl1
:question
set /p question=Some file could not be deleted. Do you wish to start exterminator mode? Y/N:
if /I "%question%"=="y" (
goto :exterminate
) else (
goto :results
)
:exterminate
tskill explorer
ping -w 1000 -n 1 1.1.1.1>nul
:lvl2
if not exist "%~1" start explorer & goto :results
del "%~1"
if exist "%~1" (
set /a deathcount+=1
) else (
set /a killcount+=1
)
shift
goto :lvl2
:results
echo msgbox "%killcount% files have been deleted. %deathcount% files could not be deleted.",16,"Recycler" > "%temp%\results.vbs"
start "" "%temp%\results.vbs"
Regards
aGerman
Re: Need help w/ Recycler.bat
Posted: 14 Jul 2010 16:08
by aseventhmindset
THANX! It works.