首页 > 解决方案 > 我可以获得批处理项目的帮助吗?

问题描述

免责声明:(我知道我的标题不是很有描述性。这是因为我什至不知道错误发生在哪里,所以我没有太多可以放在那里的)

所以,我试图写一个无用的脚本来浪费时间,结果我很投入。它应该制作某种便携式垃圾文件。

这是代码:

@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

在我输入密码后检查它刚刚结束,没有错误消息,并且它不会删除垃圾文件夹中的文件。

标签: batch-file

解决方案


这有帮助吗?

@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

推荐阅读