【问题标题】:Can I get help for a batch project? [duplicate]我可以获得批处理项目的帮助吗? [复制]
【发布时间】:2023-03-25 08:27:01
【问题描述】:

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

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

代码如下:

@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


    【解决方案1】:

    这有帮助吗?

    @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
    

    【讨论】:

      猜你喜欢
      • 2019-10-26
      • 1970-01-01
      • 1970-01-01
      • 2011-05-01
      • 2021-09-15
      • 2015-09-14
      • 2022-06-15
      • 2011-03-09
      • 1970-01-01
      相关资源
      最近更新 更多