string manipulation, display a whole line or cut and display the part
Posted: 09 Aug 2024 05:19
Code: Select all
@ECHO OFF
SET K1=M:\REGISTRY.TXT
SET DS1=30
SET DS2=75
REM *********************************************************************
SetLocal EnableExtensions EnableDelayedExpansion
REM -------------------------------------------------------------
ECHO %K1%
ECHO.
SET CC=0
FOR /F "DELIMS=" %%V IN ('TYPE "%K1%"') DO (
SET /A CC=!CC!+1
IF !CC! GEQ 1 IF !CC! LEQ 9 SET DD= !CC!
IF !CC! GTR 9 SET DD=!CC!
SET VV=%%V
ECHO !DD! !VV:~%DS1%,%DS2%!
IF !CC! EQU 35 GOTO SCREEN_FULL
)
ECHO.
SET VAR=DUMMY
SET /P VAR=INPUT:
IF %VAR%==DUMMY GOTO :END1
ECHO.
:SCREEN_FULL
HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
HKEY_USERS\S-1-5-21-790525478-796845957-725345543-1003\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Favorites
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu
HKEY_CLASSES_ROOT\Applications
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSLicensing
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer
HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\map2A\command
HKEY_CLASSES_ROOT\exefile\shellex\ContextMenuHandlers\PintoStartScreen\1111111111\222222222222\333333333\AAAAAAAAAAA\BBBBBBB\CCCCCCCCCCC
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
HKEY_CLASSES_ROOT\Applications\titanfall2.exe
HKEY_CLASSES_ROOT\Valve.Source
my question is
if the line is not long like "HKEY_CLASSES_ROOT\Applications", if the line is less than 70, display the whole line content
if the line is long then use DS1 and DS2 and cut a part and display from 30 to 75
SET DS1=30
SET DS2=75
would you fix the batch for me?
i only need some display to identify the registry with my eyes
it is better displaying the end part of a line as much as possible than the front part for me to identify the registry, then i can feed the registry to nircmd to get there