I am going crazy over a "pause" statement not working a batch file I made to clean USB drives from a virus which seems to be widespread where I work.
I found out from my researches that such problems may occur when you call another batch file and it fails or has an exit statement, and used "call" to prevent it from happening.
The problem is, the batch file keeps going, it does not stop, it works quite nicely, but it just ignores all but the first pause occurence.
Another thing is, when I use @echo off, it won't work no matter what. If I REM @echo off and run the batch from cmd, pauses will fail on the first run, then if I run it one more time then pauses will work just fine.
I just can't seem to fine why this happens despite looking for solutions all over the internet.
I left the vanity title/signature thingy only because it might be one of the reason, but I did try without it and it still would not work.
Here is the code:
@echo off
mode con: cols=80 lines=30
title USBFix by Tamok
:Signature
echo " __ __ _______..______ _______ __ ___ ___"
echo "| | | | / || _ \ | ____|| | \ \ / /"
echo "| | | | | (----`| |_) | | |__ | | \ V / "
echo "| | | | \ \ | _ < | __| | | > < "
echo "| `--' | .----) | | |_) | | | | | / . \ "
echo " \______/ |_______/ |______/ |__| |__| /__/ \__\"
echo Par T. Tamok
echo Version 0.1
echo.
echo.
echo Bienvenue dans le programme de desinfection de clefs USB et volumes externes. Appuyez sur une touche pour continuer.
pause >nul
echo.
echo Voici une liste des disques reconnus sur votre ordinateur.
echo.
call wmic logicaldisk get caption,providername,drivetype,volumename
echo.
:Volume Check
set /p vName=Veuillez saisir la lettre correspondant au volume que vous souhaitez reparer :
if not exist %vName%:\nul goto :failed
:Repair
echo Appuyez sur une touche pour continuer la reparation ou fermez la fenetre pour quitter.
pause >nul
echo Reparation en cours, veuillez patienter...
call attrib -h -r -s /s /d %vName%:\*.*
echo Restauration des fichiers caches terminee. Suppression des fichiers infectes...
if exist %vName%:\iTunesHelper.vbe goto :vbdel
echo Pas de virus iTunesHelper.vbe.
:keep1
if exist %vName%:\*.lnk goto :lnkdel
echo Pas de fichiers .lnk.
:keep2
goto :eof
:failed
echo Cette lettre ne correspond a aucun volume. Appuyez sur une touche pour quitter.
goto :eof
:vbdel
del %vName%:\iTunesHelper.vbe
echo Virus iTunesHelper.vbe repere.
echo Suppression de iTunesHelper.vbe OK.
goto keep1
:lnkdel
del %vName%:\*.lnk
echo Suppression des fichiers .lnk OK.
goto keep2
:eof
pause >nul
:exit