dremin / RetroBar

Classic Windows 95, 98, Me, 2000, XP, Vista taskbar for modern versions of Windows
Apache License 2.0
2.87k stars 265 forks source link

Set Theme from Command Line #958

Open manaphychu opened 4 days ago

manaphychu commented 4 days ago

Is there a way to set the RetroBar Theme from the Command Line? For Example: Luna, is something I want to set it as

ghost commented 4 days ago

Is there a way to set the RetroBar Theme from the Command Line? For Example: Luna, is something I want to set it as

not build-in to RetroBar, but here is a bat file that does exactly that.

save as ChangeRetroBarTheme.bat and run as administrator (check that the retrobar path is correct on the end of the file)

Example of theme name to type if you want to change to win xp blue:

Windows XP Blue

dont include " " in the theme name or .xaml, just the name of the theme.

@echo off
setlocal enabledelayedexpansion

:: Define the path to the settings.json file
set "file_path=%LocalAppData%\RetroBar\settings.json"

:: Check if the file exists
if not exist "%file_path%" (
    echo File not found: %file_path%
    pause
    exit /b
)

:: Prompt the user for the new theme value
set /p new_theme=Enter the new theme: 

:: Create a temporary file
set "temp_file=%file_path%.new"

:: Process the file line by line
(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"

:: Replace the original file with the updated one
move /y "%temp_file%" "%file_path%" >nul

echo Theme updated successfully to "%new_theme%".

:: Kill the RetroBar process
taskkill /f /im RetroBar.exe >nul 2>&1

:: Start RetroBar again
start "" "C:\Program Files\RetroBar\RetroBar.exe"

echo RetroBar has been restarted.
pause
ghost commented 4 days ago

and if you want the bat to not ask user for theme name, do this:

change

set /p new_theme=Enter the new theme:

to

set "new_theme=Windows XP Blue"

and remove the "pause" from the end of the bat

manaphychu commented 4 days ago

trying to get this to work but won't

ghost commented 4 days ago

trying to get this to work but won't

what is the theme file name?

Luna.xaml or what?

manaphychu commented 4 days ago

I am trying to change this to XP Blue but won't change theme, any other way to make it work with the BAT File for changing the entire theme of Windows?

manaphychu commented 4 days ago

trying to get this to work but won't

what is the theme file name?

Luna.xaml or what?

@echo off setlocal enabledelayedexpansion

:: Define the path to the settings.json file set "file_path=%LocalAppData%\RetroBar\settings.json"

:: Check if the file exists if not exist "%file_path%" ( echo File not found: %file_path% pause exit /b )

:: Prompt the user for the new theme value set new_theme=Windows XP Blue

:: Create a temporary file set "temp_file=%file_path%.new"

:: Process the file line by line ( for /f "usebackq delims=" %%i in ("%file_path%") do ( set "line=%%i" echo !line! | findstr /c:"\"Theme\"" >nul if not errorlevel 1 ( echo "Theme": "!new_theme!", ) else ( echo !line! ) ) ) > "%temp_file%"

:: Replace the original file with the updated one move /y "%temp_file%" "%file_path%" >nul

echo Theme updated successfully to "%new_theme%".

:: Kill the RetroBar process taskkill /f /im RetroBar.exe >nul 2>&1

:: Start RetroBar again start C:\Classic\RetroBar\RetroBar.exe

echo RetroBar has been restarted.

here's the command

ghost commented 4 days ago

the command you used for set windows xp blue is wrong,

try this one: (see the difference?)

@echo off
setlocal enabledelayedexpansion

set "new_theme=Windows XP Blue"
set "file_path=%LocalAppData%\RetroBar\settings.json"

if not exist "%file_path%" (
    echo File not found: %file_path%
    pause
    exit /b
)

set "temp_file=%file_path%.new"

(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"

move /y "%temp_file%" "%file_path%" >nul

taskkill /f /im RetroBar.exe
start "" "C:\Program Files\RetroBar\RetroBar.exe"
manaphychu commented 4 days ago

still nope...

the command you used for set windows xp blue is wrong,

try this one: (see the difference?)

@echo off
setlocal enabledelayedexpansion

set "new_theme=Windows XP Blue"
set "file_path=%LocalAppData%\RetroBar\settings.json"

if not exist "%file_path%" (
    echo File not found: %file_path%
    pause
    exit /b
)

set "temp_file=%file_path%.new"

(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"

move /y "%temp_file%" "%file_path%" >nul

taskkill /f /im RetroBar.exe
start "" "C:\Program Files\RetroBar\RetroBar.exe"

still nope

ghost commented 4 days ago

what is the path to retrobar.exe?

this bat works fine on my end

manaphychu commented 4 days ago

what is the path to retrobar.exe?

this bat works fine on my end

for me: C:\Classic\RetroBar

ghost commented 4 days ago

C:\Classic\RetroBar

@echo off
setlocal enabledelayedexpansion

set "new_theme=Windows XP Blue"
set "file_path=%LocalAppData%\RetroBar\settings.json"

if not exist "%file_path%" (
    echo File not found: %file_path%
    pause
    exit /b
)

set "temp_file=%file_path%.new"

(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"

move /y "%temp_file%" "%file_path%" >nul
taskkill /f /im RetroBar.exe
start "" "C:\Classic\RetroBar\RetroBar.exe"

test: 1

manaphychu commented 4 days ago

C:\Classic\RetroBar

@echo off
setlocal enabledelayedexpansion

set "new_theme=Windows XP Blue"
set "file_path=%LocalAppData%\RetroBar\settings.json"

if not exist "%file_path%" (
    echo File not found: %file_path%
    pause
    exit /b
)

set "temp_file=%file_path%.new"

(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"

move /y "%temp_file%" "%file_path%" >nul
taskkill /f /im RetroBar.exe
start "" "C:\Classic\RetroBar\RetroBar.exe"

test: 1

not working for me?!

ghost commented 4 days ago

you need to run it as administrator:

shift+rightclick the bat file and select "run as administrator"

manaphychu commented 4 days ago

still no sign of theme changing

ghost commented 4 days ago

still no sign of theme changing

can you save it to c:\classic\changetheme.bat

then hit windowsbutton+r and type "cmd"

now type "c:\classic\changetheme.bat" take a screenshot and send here so we can see if it gives some kind of error.

manaphychu commented 4 days ago

image ughhh... it won't, god dammit windows

ghost commented 4 days ago

ok so there is a permission error, you dont have admin rights apparently

manaphychu commented 4 days ago

ok so there is a permission error, you dont have admin rights apparently

how do I make it not reject the change? without admin permissions?

ghost commented 4 days ago

type this to cmd

net user %username%

does it say "administrators" at the bottom?

manaphychu commented 4 days ago

yeah

ghost commented 4 days ago

well try closing retrobar manually and then run the bat when retrobar is not running

if this works, then something is blocking the taskkill command, might be antivirus protecting you?

manaphychu commented 4 days ago

idk?

ghost commented 4 days ago

test running the bat when retrobar is closed and i might have a possible fix for you, first we need to find the problem

manaphychu commented 4 days ago

because it won't change theme when open

ghost commented 4 days ago

because it won't change theme when open

it will change, but on your case it does not. so try this then, it closes retrobar first:

@echo off
setlocal enabledelayedexpansion

set "new_theme=Windows XP Blue"
set "file_path=%LocalAppData%\RetroBar\settings.json"

taskkill /f /im RetroBar.exe
if not exist "%file_path%" (
    exit /b
)
set "temp_file=%file_path%.new"
(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"
move /y "%temp_file%" "%file_path%" >nul
start "" "C:\Classic\RetroBar\RetroBar.exe"
manaphychu commented 4 days ago

uuuughhh! nope.... it doesn't...

ghost commented 4 days ago

type this to cmd and take a screenshot:

tasklist /fi "imagename eq RetroBar.exe"
manaphychu commented 4 days ago

where do I put it in?

manaphychu commented 4 days ago

my PID for RetroBar is 3696

ghost commented 4 days ago

my PID for RetroBar is 3696

take screenshot so i can see if these give error, type exactly what i typed: 1

manaphychu commented 3 days ago

The process cannot access the file because it is being used by another process.... :( TWO TIMES! image

ghost commented 3 days ago

The process cannot access the file because it is being used by another process.... :(

do you have something else also running? like OpenShell or similar? that might be the reason this is failing

another possibilities: no administrator access antivirus is blocking taskkill command

manaphychu commented 3 days ago

no admin access... :(

manaphychu commented 3 days ago

Dremin needs to make a new feature where you can set the theme from one single command line without restart

manaphychu commented 3 days ago

image because I was working on a modification of the Windows eXPerience Extras Pack Theme Changer for my Windows 11 Customization Pack

ghost commented 3 days ago

well i will make it for you, maybe an hour and it is done? probably, lets see (no promises)

give me some details what you want from the cmd command?

RetroBar.exe -ChangeTheme "Windows Xp Blue"

is this good?

manaphychu commented 3 days ago

lemme try

ghost commented 3 days ago

I mean i can make a feature for it and the make a pull request so you can download a retrobar with cmd functionality, that is not a problem, i can do it if you want something like that.

manaphychu commented 3 days ago

sure

ghost commented 3 days ago

ok, i will post it here when it is done.

manaphychu commented 3 days ago

thx

ghost commented 3 days ago

yeah i have it working now, i am just cleaning code, mayb 10 minutes and you can test

ghost commented 3 days ago

here you go:

https://github.com/dremin/RetroBar/pull/959

ghost commented 3 days ago

i tested and it works fine on my system. details on the pull request.

manaphychu commented 3 days ago

nope, download failed, something went wrong.

manaphychu commented 3 days ago

it detected a threat... what a pain in the ass for me..

ghost commented 3 days ago

you can compile it yourself too if you have visual studio

ghost commented 3 days ago

it is no trojan for sure, i just compiled it myself https://www.mediafire.com/file/bvmkene8a8kut56/RetroBar-cmd-net6.0-windows.rar

manaphychu commented 3 days ago

download failed again... 😭

manaphychu commented 3 days ago

WHY WINDOWS DEFENDER?!!?