Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal enabledelayedexpansion
- cd /d "%~dp0"
- cls
- echo.
- echo.
- echo.
- echo ################################################
- echo # 'Create sorted list of Banished mods' #
- echo # release 6b #
- echo # by Gordon Dry #
- echo ################################################
- echo ########## ugly simple soft #########
- echo.
- echo.
- GOTO check_Permissions
- :CHECK
- echo.
- echo Checking for registry key in HKEY_CURRENT_USER\Software\Shining Rock Software LLC\Banished
- REG QUERY "HKEY_CURRENT_USER\Software\Shining Rock Software LLC\Banished" /v GameLastStart
- IF %errorlevel%==0 GOTO EXPORTCU
- echo.
- echo Checking for registry key in HKEY_LOCAL_MACHINE\Software\Shining Rock Software LLC\Banished
- REG QUERY "HKEY_LOCAL_MACHINE\Software\Shining Rock Software LLC\Banished" /v GameLastStart
- echo.
- IF %errorlevel%==0 GOTO EXPORTLM
- IF %errorlevel%==1 GOTO FAILED
- :EXPORTCU
- set "key=cu"
- echo - Exporting Banished registry key
- start /wait regedit.exe /a "Banished registry export.reg" "HKEY_CURRENT_USER\Software\Shining Rock Software LLC\Banished"
- GOTO SORT
- :EXPORTLM
- set "key=lm"
- echo - Exporting Banished registry key
- start /wait regedit.exe /a "Banished registry export.reg" "HKEY_LOCAL_MACHINE\Software\Shining Rock Software LLC\Banished"
- GOTO SORT
- :SORT
- echo - Clearing the export to new file
- findstr "ModIndex_" "Banished registry export.reg" > "List of Banished mods.txt"
- echo - Sorting the list simply
- sort "List of Banished mods.txt" /O "List of Banished mods.txt"
- echo - Deleting temporary files so far
- if exist "Sorted list of Banished mods.txt" del "Sorted list of Banished mods.txt"
- if exist "Temp list of Banished mods.txt" del "Temp list of Banished mods.txt"
- if exist "Temp2 list of Banished mods.txt" del "Temp2 list of Banished mods.txt"
- if exist "Temp3 list of Banished mods.txt" del "Temp3 list of Banished mods.txt"
- if exist "Delete obsolete registry entries.reg" del "Delete obsolete registry entries.reg"
- echo - Applying a real sorting by index number
- cmsort\cmsort.exe /V=$3D,$22 /NV=2,1,0 "List of Banished mods.txt" "List of Banished mods.txt"
- echo.
- echo - Cleaning up all unnecessary entries by multiple steps
- echo - step 1
- FOR /F "usebackq delims=" %%G IN ("List of Banished mods.txt") DO (
- Set "line=%%G" & echo !line:"=!
- )>>"Temp List of Banished mods.txt"
- echo - step 2
- FOR /F "usebackq tokens=*" %%G IN (`findstr /L "ModIndex_" "Temp List of Banished mods.txt"`) DO (
- set "line=%%G"
- set str=!line:ModIndex_=!
- echo !str!
- )>>"Temp2 List of Banished mods.txt"
- echo - step 3
- echo REGEDIT4>"Delete obsolete registry entries.reg"
- echo.>>"Delete obsolete registry entries.reg"
- echo [HKEY_CURRENT_USER\Software\Shining Rock Software LLC\Banished]>>"Delete obsolete registry entries.reg"
- set /a x=0
- FOR /F "usebackq tokens=1 delims==" %%G IN ("Temp2 List of Banished mods.txt") DO (
- Set "line=%%G"
- echo !line!.pkm
- if not exist WinData\!line!.pkm (
- echo "ModIndex_!line!"=->>"Delete obsolete registry entries.reg"
- echo "ModEnabled_!line!"=->>"Delete obsolete registry entries.reg"
- set /a x+=1
- set deletekey[!x!]=!line!
- )
- )>>"Temp3 List of Banished mods.txt"
- echo.
- echo - Checking if a mod is listed in the registry but no more inside WinData folder
- echo #######################################################>"Sorted List of Banished mods.txt"
- echo # List of Banished mods sorted by load order #>>"Sorted List of Banished mods.txt"
- echo # created with #>>"Sorted List of Banished mods.txt"
- echo # 'Create sorted list of Banished mods' #>>"Sorted List of Banished mods.txt"
- echo # release 6b #>>"Sorted List of Banished mods.txt"
- echo # by Gordon Dry #>>"Sorted List of Banished mods.txt"
- echo #######################################################>>"Sorted List of Banished mods.txt"
- echo ################### ugly simple soft ##################>>"Sorted List of Banished mods.txt"
- echo # http://worldofbanished.com/index.php?topic=790.0 #>>"Sorted List of Banished mods.txt"
- echo #######################################################>>"Sorted List of Banished mods.txt"
- echo.>>"Sorted List of Banished mods.txt"
- FOR /F "usebackq tokens=*" %%G IN ("Temp3 List of Banished mods.txt") DO (
- Set "line=%%~nG"
- if exist WinData\!line!.pkm (
- set "ValueName=ModEnabled_!line!"
- if key=="lm" (
- for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\Software\Shining Rock Software LLC\Banished" /v !ValueName!') do set MODSTATUS=%%b
- ) else (
- for /f "tokens=2*" %%a in ('reg query "HKEY_CURRENT_USER\Software\Shining Rock Software LLC\Banished" /v !ValueName!') do set MODSTATUS=%%b
- )
- if !MODSTATUS!==false (
- echo !line! - - - - - - MOD DISABLED
- ) else (
- echo !line!
- )
- ) else (
- echo !line! - - - - - - NO MORE in WinData folder
- )
- )>>"Sorted List of Banished mods.txt"
- if !x! GTR 0 (
- echo - The following mods are no more in the WinData folder but in the registry:
- echo.
- for /L %%y IN (1 1 !x!) DO (
- echo - !deletekey[%%y]!.pkm
- )
- echo.
- choice /C YN /M "Do you want these obsolete registry entries to be deleted"
- IF !errorlevel!==1 goto DELETEEMPTY
- IF !errorlevel!==2 goto NEARLY
- ) else (
- echo - no obsolete mod entries found
- goto NEARLY
- )
- :DELETEEMPTY
- if exist "Banished registry export.reg" del "Banished registry backup.reg" | ren "Banished registry export.reg" "Banished registry backup.reg"
- echo.
- echo - Deleting obsolete registry entries
- reg IMPORT "Delete obsolete registry entries.reg"
- echo.
- echo Checking again ...
- timeout /T 3
- goto CHECK
- :NEARLY
- if exist "Banished registry export.reg" del "Banished registry backup.reg" | ren "Banished registry export.reg" "Banished registry backup.reg"
- echo - Deleting temporary files finally
- echo.
- del "List of Banished mods.txt"
- del "Temp list of Banished mods.txt"
- del "Temp2 list of Banished mods.txt"
- del "Temp3 list of Banished mods.txt"
- del "Delete obsolete registry entries.reg"
- if exist "Banished registry export.reg" del "Banished registry export.reg"
- echo The file "Banished registry backup.reg" includes the registry key as it was before the whole process ...
- echo.
- choice /C YN /M "Do you want the file 'Banished registry backup.reg' to be deleted"
- IF !errorlevel!==1 del "Banished registry backup.reg"
- echo.
- echo Done!
- echo.
- GOTO END
- :FAILED
- echo.
- echo.
- echo I was neither able to find the registry key
- echo HKEY_CURRENT_USER\Software\Shining Rock Software LLC\Banished
- echo.
- echo nor the registry key
- echo HKEY_LOCAL_MACHINE\Software\Shining Rock Software LLC\Banished
- echo.
- echo.
- echo Aborting...
- echo.
- GOTO END
- :check_Permissions
- echo Administrative permissions required. Detecting permissions...
- net session >nul 2>&1
- if %errorLevel% == 0 (
- echo Success: Administrative permissions confirmed.
- GOTO CHECK
- ) else (
- echo Failure: Current permissions inadequate.
- echo.
- echo Please restart this batch with administrative privileges after it quits.
- echo.
- echo You can do this by right-clicking the file "Create sorted list of Banished mods.cmd" and choose "Run as administrator"
- echo.
- echo.
- )
- :END
- echo Press a key to exit ... you have 20 seconds to comply
- echo.
- echo (c) 1989 Silver Bullet
- echo https://www.musixmatch.com/de/songtext/Silver-Bullet/20-Seconds-to-Comply
- timeout /T 20
- endlocal enabledelayedexpansion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement