1

Disclaimer: (I know my title isn't very descriptive. Its because I don't even know where the error is happening so there is not much for me to put there)

So, I was trying to write a useless script to waste time and I ended up getting quite into it. It was supposed to make some sort of portable trash file.

here is the code:

@echo off


if not EXIST trash goto create
if EXIST trash goto exists

:create
mkdir trash
goto end

:exists
echo Would you like to delete the files inside of the trash? (y/n)
set /p YESNO=" "
if %YESNO%==n goto end
if %YESNO%==y goto check

:check
echo Please state the correct password
set /p PASSWORD = " "
if %PASSWORD%==1243 del trash\*.* /s /f /q
pause

:end

in check after I input the password it just ends, no error message, and it doesn't delete the files inside the trash folder .

CJendantix
  • 23
  • 7

1 Answers1

2

Does this help?

@Echo Off
If Exist "trash\" GoTo exists

:create
(MD "trash" 2>NUL || Echo Failed to create trash!) & GoTo :EOF

:exists
%SystemRoot%\System32\choice.exe /M "Would you like to empty the trash"
If ErrorLevel 2 GoTo :EOF

:check
Set /P "password=Please enter the correct password>"
If "%password%" == "1243" PushD "trash" && RD /S /Q . 2>NUL & Echo Done! & PopD

Pause
Compo
  • 36,585
  • 5
  • 27
  • 39