Jump to content

Recommended Posts

Marthastewart
Posted

 

I have Emby Server installed on windows 11 running as a service through NSSM. Whenever I do the manual update, to get a new version of Emby something always messes up (database corrupted, user profile missing etc). I have given up on that manual install or Emby Server to update it process.

My work around is to delete the NSSM service for Emby -> update Emby in the web GUI (update, then restart) -> then resetup Emby as a service through NSSM.

This manual process always works, but takes like 5 or 10 minutes of manual clicking. However, I never have an update issue. So I decided to make a script out of it, which mostly automates the entire process (see attached .txt file for script).

  1. Save the script as a .bat file extension
  2.  run script as admin (you will see terminal pop up and sit there with an explanation - see attached screenshot)
  3.  it will relaunch Emby for you (assume in Edge browser)
  4. You need to click update Emby in GUI
  5. You need to click restart Emby
  6. You need to go back to terminal window and press any key to resume script -> Emby is configured as a service again. Done.

----------------------------

This assumes that you have OS Windows 11, Embyserver installed on it, and NSSM installed. See attached screenshot for sample output of script if interested. 

The only thing you should need to change is the "sets" at the beginning of the script.

  • Set 1 - whatever you currently have NSSM service called to run Emby as a service. I simply named mine "Emby"
  • Set 2 & 3. You need to update your windows 11 user profile name. My windows user profile is called "Emby". Yours might be Bob or whatever "users\bob\appdata etc"
  • Set 4 leave it alone
@echo off
setlocal
:: --- CONFIGURATION ---
set "SERVICE_NAME=Emby"
set "EMBY_EXE=C:\Users\Emby\AppData\Roaming\Emby-Server\system\EmbyServer.exe"
set "EMBY_DIR=C:\Users\Emby\AppData\Roaming\Emby-Server\system"
set "DASHBOARD_URL=http://localhost:8096/web/index.html#!/dashboard"

:: Admin Check
net session >nul 2>&1
if %errorLevel% neq 0 (
    echo [ERROR] Please run this script as Administrator.
    pause
    exit /b
)

echo [1/5] Stopping and removing NSSM service...
nssm stop "%SERVICE_NAME%"
nssm remove "%SERVICE_NAME%" confirm

echo [2/5] Launching Emby GUI and opening Edge...
start "" "%EMBY_EXE%"
start msedge "%DASHBOARD_URL%"

echo.
echo ---------------------------------------------------------
echo ACTION REQUIRED:
echo 1. In the Edge window that just opened, click 'Update'.
echo 2. When the update is done, click 'Restart' in the Dashboard.
echo ---------------------------------------------------------
echo.
echo WAIT until the Edge page refreshes and says "Yay! You are up to date."
echo THEN, come back here and...
echo.
pause

echo [4/5] Cleaning up manual processes...
taskkill /F /IM EmbyServer.exe /T 2>nul
timeout /t 2 >nul

echo [5/5] Reinstalling NSSM service...
nssm install "%SERVICE_NAME%" "%EMBY_EXE%"
nssm set "%SERVICE_NAME%" AppDirectory "%EMBY_DIR%"
nssm set "%SERVICE_NAME%" AppParameters "-service"
nssm set "%SERVICE_NAME%" AppExit Default Exit

echo [OK] Starting Service...
nssm start "%SERVICE_NAME%"

echo.
echo Update Complete! The NSSM service is back online.
pause

 

Script output.png

Posted

Thanks for sharing.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...