I made a script that deletes jmeter records, but can't delete the file, does anyone know what's the problem?
ECHO: Delete Info folder under HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\org\apache\jmeter\gui\action
for /f %%i in ('"%SystemRoot%\System32\reg.exe QUERY "HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\org\apache\jmeter\gui\action" /s | %SystemRoot%\System32\findstr.exe /E "recent_file.*""') do (
reg delete %%i /f
)
ECHO Finish
pause
Output:
D:\>ECHO: Delete Info folder under HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\org\apache\jmeter\gui\action
Delete Info folder under HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\org\apache\jmeter\gui\action
D:\>for /F %i in ('"C:\Windows\System32\reg.exe QUERY "HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\org\apache\jmeter\gui\action" /s | C:\Windows \System32\findstr.exe /E "recent_file.*""') do (reg delete %i /f )
D:\>(reg delete recent_file_0 /f )
Error: Invalid item name.
Type "REG DELETE /?" for usage information.
D:\>ECHO Finish
Finish
D:\>pause
Please press any key to continue . . .
It can be queried through regular expressions, but cannot be deleted. The solution is to delete all keys in the action directory, which works, not what i expected.
CodePudding user response:
After testing on windows 10, this method works.
@echo off
echo Delete Info folder under HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\org\apache\jmeter\gui\action
for /f %%i in ('"REG QUERY "HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\org\apache\jmeter\gui\action" /s | findstr /E recent_file.* "') do (
reg delete "HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\org\apache\jmeter\gui\action" /v %%i /f
)
echo Finish
pause
CodePudding user response:
This is how I'd probably try it, based upon the limited information you've offered, and the below image, to cover the information you omitted:
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
Set "subKey=HKCU\SOFTWARE\JavaSoft\Prefs\org\apache\jmeter\gui\action"
For /F EOL^=H %%G In ('%SystemRoot%\System32\reg.exe Query "%subKey%" /F
"recent_file_*" /V 2^>NUL ^| %SystemRoot%\System32\find.exe "_"'
) Do %SystemRoot%\System32\reg.exe Delete "%subKey%" /V "%%G" /F