Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
aseventhmindset
- Posts: 8
- Joined: 11 Apr 2010 20:55
#1
Post
by aseventhmindset » 14 Jul 2010 01:28
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
-
alan_b
- Expert
- Posts: 357
- Joined: 04 Oct 2008 09:49
#2
Post
by alan_b » 14 Jul 2010 02:37
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
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#3
Post
by aGerman » 14 Jul 2010 04:46
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
-
avery_larry
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
#4
Post
by avery_larry » 14 Jul 2010 11:03
Also, since %temp% could include spaces:
start "" "%temp%\results.vbs"
-
aseventhmindset
- Posts: 8
- Joined: 11 Apr 2010 20:55
#5
Post
by aseventhmindset » 14 Jul 2010 15:07
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
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#6
Post
by aGerman » 14 Jul 2010 16:02
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