samedi 1 août 2020

IF statement in windows command line

Ive created a script to do a certain task to remove a folder before starting a java bot.

However ive run into a problem where the Command Line closes at a certain line because the folders are not there (already deleted).

How can i implement an IF statement to state to do the next task if the File Not Found instead of the CMD closing.

set "bot=%cd%"
echo %USERNAME%
cd C:\Users\%USERNAME%\AppData\Local\Temp
for /f %i in ('dir /a:d /s /b scoped*') do rd /s /q %i 
cd %bot%
java -jar Bot.jar
taskkill /F /IM chromedriver.exe

It seems to be closing on this line

for /f %i in ('dir /a:d /s /b scoped*') do rd /s /q %i 

as the folders "scoped" have already been removed. I want it to continue to do the next lines if this is the case.

Aucun commentaire:

Enregistrer un commentaire