gpt4 book ai didi

batch-file - 如何修复该批处理文件? (打字机效果)

转载 作者:行者123 更新时间:2023-12-03 07:43:18 25 4
gpt4 key购买 nike

我想使批处理脚本具有打字机样式/效果,同时删除文件并显示回声和内容。我希望它看起来像这样:

:Write1
echo Deleting Prefetches...
del /s /q "C:\Windows\Prefetch\JAVAW*.pf"
echo Prefetches Deleted.
pause && goto :Write2
(Then Write2 would delete stuff, display messages and go to Write3 and so on.

这不是我实现的确切代码,但非常相似。
我有这段代码(很长),我想知道是否有人可以对它进行错误修补或只是找出问题所在,因为它会自我重复并且在暂停后不会消失。到目前为止,这是我的全部信息(请注意,它删除的文件不是系统文件,并且是快捷方式和注册表项,它们什么都不做。可以进行清洁测试。)
@echo off
:: %len_% holds the value of the length of the string input

setlocal enabledelayedexpansion
call :Write "Deleting Prefetches..."
del /s /q "C:\Windows\Prefetch\VAPE*.pf"
del /s /q "C:\Windows\Prefetch\JAVAW*.pf"
echo Prefetches Deleted!
pause && goto :Write2

setlocal enabledelayedexpansion
call :Write2 "Deleting Shellbags..."
reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell /va /f
reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Bags /va /f
reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\BagMRU /va /f
reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU /VA /F
reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths /VA /F
reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU /va /f
echo Shellbags Deleted!
pause && goto :Write3

setlocal enabledelayedexpansion
call :Write3 "Deleting Temp Files..."
for /d %%i in ("%TEMP%\Rar$EXa0.???") do rd "%TEMP%\%%i"
for /d %%i in ("%TEMP%\Rar$DIa0.???") do rd "%TEMP%\%%i"
rd /s /q "C:\Users\%USERNAME%\AppData\Local\Temp\Rar$EXa0.*.*"
del /s /q "C:\Users\%USERNAME%\AppData\Local\Temp\Rar$EXa0.*.*"
attrib -H "C:\Users\%USERNAME%\AppData\Local\Temp\etilqs_*.*"
del /s /q "C:\Users\%USERNAME%\AppData\Local\Temp\etilqs_*.*"
echo Temp Files Deleted!
pause && goto :Write4

setlocal enabledelayedexpansion
call :Write4 "Deleting Recent Items..."
del /s /q "?C:\Users\%USERNAME%\Recent\SDHC (E) (2).lnk"
del /s /q "?C:\Users\%USERNAME%\Recent\SDHC (E).lnk"
del /s /q "C:\Users\%USERNAME%\Recent\*.ahk.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\1.7.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\1.8.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Vape Launcher.exe.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Vape.jar.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\.vs.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Common.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Jar Injector.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Vape Launcher.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Vape Launcher.sln.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\v14.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\.suo.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Memory.c.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Memory.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\include.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\jdk.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\win32.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\classfile_constants.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\jawt.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\jdwpTransport.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\jni.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\jvmti.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\jvmticmlr.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\bridge.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\jawt_md.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\jni_md.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\AccessBridgeCallbacks.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\AccessBridgeCalls.c.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\AccessBridgeCalls.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\AccessBridgePackages.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\DllMain.c.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Jar Injector.vcxproj.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Jar Injector.vcxproj.filters.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Jar Injector.vcxproj.user.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\ReflectiveDLLInjection.h"
del /s /q "C:\Users\%USERNAME%\Recent\ReflectiveLoader.c.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\ReflectiveLoader.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\GetProcAddressR.c.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\GetProcAddressR.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\LoadLibraryR.c.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\LoadLibraryR.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\ReflectiveDLLInjection.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\resource.h.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Vape Launcher.rc.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Vape Launcher.vcxproj.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Vape Launcher.vcxproj.filters.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\Vape Launcher.vcxproj.user.lnk"
del /s /q "C:\Users\%USERNAME%\Recent\WinMain.c.lnk"
echo Recent Items Deleted!
pause && goto :Write5

setlocal enabledelayedexpansion
call :Write5 "Deleting Recycled Items..."
del /s /q "C:\$RECYCLE.BIN\*.lnk"
del /s /q "C:\$RECYCLE.BIN\*.pf"
rd /s /q "C:\$RECYCLE.BIN\Rar$EXa0.*.*"
del /s /q "C:\$RECYCLE.BIN\Rar$EXa0.*.*"
rd /s /q "C:\$RECYCLE.BIN\Rar$DIa0.*.*"
del /s /q "C:\$RECYCLE.BIN\Rar$DIa0.*.*"
del /s /q "C:\$RECYCLE.BIN\etilqs_*.*"
echo Recycled Items Deleted!
pause && goto :eof

:Write
set string=%1
call :GetLength %string%
set string=%string:"=%
set /a length=%len_%
for /l %%A in (1,1,%length%) do (
cls
echo !string:~0,%%A!
ping localhost -n 1 -w 500 -l 5000 > nul
)

:Write2
set string=%1
call :GetLength %string%
set string=%string:"=%
set /a length=%len_%
for /l %%A in (1,1,%length%) do (
cls
echo !string:~0,%%A!
ping localhost -n 1 -w 500 -l 5000 > nul
)

:Write3
set string=%1
call :GetLength %string%
set string=%string:"=%
set /a length=%len_%
for /l %%A in (1,1,%length%) do (
cls
echo !string:~0,%%A!
ping localhost -n 1 -w 500 -l 5000 > nul
)

:Write4
set string=%1
call :GetLength %string%
set string=%string:"=%
set /a length=%len_%
for /l %%A in (1,1,%length%) do (
cls
echo !string:~0,%%A!
ping localhost -n 1 -w 500 -l 5000 > nul
)

goto :eof

:GetLength
set str=%1
set /a len=1
:loop
set /a len_=%len% - 1
if "!str:~0,%len%!"=="!str:~0,%len_%!" goto done
set /a len+=1
goto loop

:done
set /a len_-=2
goto :eof

最佳答案

您不需要调用相同的函数:Write1 :write2 :write3 :write3..等等。

您只需要一个函数TypeWriter即可根据需要调用它,因此,只需调用它就可以节省很多代码,例如以下代码:

@echo off
Title Example of TypeWriter
color 0A
setlocal enabledelayedexpansion
call :TypeWriter "http://stackoverflow.com/questions/40011157/how-do-i-fix-this-batch-file-typewriter-effect"
pause && goto Next
::************************************************
:TypeWriter
set string=%1
call :GetLength %string%
set string=%string:"=%
set /a length=%len_%
for /l %%A in (1,1,%length%) do (
cls
echo !string:~0,%%A!
ping localhost -n 1 -w 500 -l 5000 > nul
)
::************************************************
:GetLength
set str=%1
set /a len=1
::************************************************
:loop
set /a len_=%len% - 1
if "!str:~0,%len%!"=="!str:~0,%len_%!" goto done
set /a len+=1
goto loop
::************************************************
:done
set /a len_-=2
goto :eof
::************************************************
:Next
color 0C
Call :TypeWriter "Deleting Recycled Items..."
Call :TypeWriter "echo del /s /q "C:\$RECYCLE.BIN\*.lnk""
echo del /s /q "C:\$RECYCLE.BIN\*.lnk"
Call :TypeWriter "echo del /s /q "C:\$RECYCLE.BIN\*.pf""
echo del /s /q "C:\$RECYCLE.BIN\*.pf"
Call :TypeWriter "echo rd /s /q "C:\$RECYCLE.BIN\Rar$EXa0.*.*""
echo rd /s /q "C:\$RECYCLE.BIN\Rar$EXa0.*.*"
Call :TypeWriter "echo del /s /q "C:\$RECYCLE.BIN\Rar$EXa0.*.*"
echo del /s /q "C:\$RECYCLE.BIN\Rar$EXa0.*.*"
Call :TypeWriter "echo rd /s /q "C:\$RECYCLE.BIN\Rar$DIa0.*.*""
echo rd /s /q "C:\$RECYCLE.BIN\Rar$DIa0.*.*"
Call :TypeWriter "echo del /s /q "C:\$RECYCLE.BIN\Rar$D.*.*"Ia0"
echo del /s /q "C:\$RECYCLE.BIN\Rar$D.*.*"Ia0
Call :TypeWriter "echo del /s /q "C:\$RECYCLE.BIN\etilqs_*.*""
echo del /s /q "C:\$RECYCLE.BIN\etilqs_*.*"
echo Recycled Items Deleted!
pause
::************************************************

编辑于13/10/2016 @ 22:05

另一个例子 :

@echo off
Call :TypeWriter "http://stackoverflow.com/questions/40011157/how-do-i-fix-this-batch-file-typewriter-effect"
pause && goto Next
::*************************************************************
:TypeWriter
echo(
(
echo strText=wscript.arguments(0^)
echo intTextLen = Len(strText^)
echo intPause = 150
echo For x = 1 to intTextLen
echo strTempText = Mid(strText,x,1^)
echo WScript.StdOut.Write strTempText
echo WScript.Sleep intPause
echo Next
)>%tmp%\%~n0.vbs
@cscript.EXE /noLogo "%tmp%\%~n0.vbs" "%~1"
echo(
exit /b
::**************************************************************
:Next
color 0C
Call :TypeWriter "Deleting Recycled Items..."
Call :TypeWriter "echo del /s /q "C:\$RECYCLE.BIN\*.lnk""
echo del /s /q "C:\$RECYCLE.BIN\*.lnk"
Call :TypeWriter "echo del /s /q "C:\$RECYCLE.BIN\*.pf""
echo del /s /q "C:\$RECYCLE.BIN\*.pf"
Call :TypeWriter "echo rd /s /q "C:\$RECYCLE.BIN\Rar$EXa0.*.*""
echo rd /s /q "C:\$RECYCLE.BIN\Rar$EXa0.*.*"
Call :TypeWriter "echo del /s /q "C:\$RECYCLE.BIN\Rar$EXa0.*.*"
echo del /s /q "C:\$RECYCLE.BIN\Rar$EXa0.*.*"
Call :TypeWriter "echo rd /s /q "C:\$RECYCLE.BIN\Rar$DIa0.*.*""
echo rd /s /q "C:\$RECYCLE.BIN\Rar$DIa0.*.*"
Call :TypeWriter "echo del /s /q "C:\$RECYCLE.BIN\Rar$D.*.*"Ia0"
echo del /s /q "C:\$RECYCLE.BIN\Rar$D.*.*"Ia0
Call :TypeWriter "echo del /s /q "C:\$RECYCLE.BIN\etilqs_*.*""
echo del /s /q "C:\$RECYCLE.BIN\etilqs_*.*"
echo Recycled Items Deleted!
pause>nul
::************************************************

关于batch-file - 如何修复该批处理文件? (打字机效果),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40011157/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com