letterman 40 Posted May 27, 2024 Posted May 27, 2024 (edited) I sloved the embytray-problem like that. CASE: Windows. I need a running EmbyServer after reboot without logging in. After logging in later, I need Embytray working, too. PROBLEM: Starting emby with Task Scheduler is easy. Just add a task Programm Start ...embyserver.exe (with Systemstart) But when logging in, Embytray ist missing, because of different execution sessions. SOLUTION: Add first scheduled task (with systemstart) to start programm C:\Users\xxx\AppData\Roaming\Emby-Server\system\EmbyServer.exe Add second scheduled task (when user logging in) to start PS-Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe args-field: -command C:\xxx\yourscriptname.ps1 I trigged the start of this script with a delay of 30 sec. # # Script to shutdown EmbyServer with POST-Method and start it again afterwards # $headers = @{ "X-Emby-Client" = "Emby Web" "X-Emby-Device-Name" = "Google Chrome Windows" # "X-Emby-Device-Id" = "xxxxx" Seems to be not necessary # "X-Emby-Client-Version"= "4.8.7.0"Seems to be not necessary "X-Emby-Token" = "YOUR API" # "X-Emby-Language" = "en-us" Seems to be not necessary } # Function to test, if EmbyServer is running. # Delayed 5 seconds, because it takes some time to startup/shutdown function Test-EmbyServerRunning { param ( [string]$ProcessName = "EmbyServer" ) $waitingTime = 3 Write-Host "Waiting $waitingTime seconds..." Start-Sleep -Seconds $waitingTime $processes = Get-Process | Where-Object { $_.Name -eq $ProcessName } if ($processes) { $timeout = 5 Write-Host "EmbyServer is still running... waiting $timeout seconds if it stopps" $endTime = (Get-Date).AddSeconds($timeout) while ((Get-Date) -lt $endTime) { $process = Get-Process -Name $ProcessName -ErrorAction SilentlyContinue if (-not $process) { # Write-Host "EmbyServer stopped." return $false } Start-Sleep -Milliseconds 500 } if ($process) { # Write-Host "Error: EmbyServer did not stop." return $true } } else { # Write-Host "Timeout: EmbyServer is not running." return $false } return $false } # Check, if EmbyServer is allready running before shutdown Write-Host "Check EmbyServer Status" $serverRunning = Test-EmbyServerRunning if ($serverRunning) { # Shutdown EmbyServer try { Write-Host "EmbyServer is running." Write-Host "Invoke Shutdown EmbyServer successfull" Invoke-RestMethod -Uri "http://localhost:8096/emby/System/Shutdown" -Method Post -Headers $headers # Check, if EmbyServer stopped Write-Host "Check EmbyServer Status" $serverRunning = Test-EmbyServerRunning if ($serverRunning) { Write-Host "EmbyServer did not stop." Write-Host "Press Enter to Exit." Read-Host exit } else { Write-Host "EmbyServer is not running. Shutdown successful." } } catch { Write-Host "Error Invoke-RestMethod: $($_.Exception.Message)" Write-Host "Press Enter to Exit." Read-Host exit } } else { Write-Host "EmbyServer is not running. Shutdown not necessary." } # Start EmbyServer try { Start-Process "C:\Users\XXXXX\AppData\Roaming\Emby-Server\system\EmbyServer.exe" # Insert your Path Write-Host "Start-Process EmbyServer successfull" } catch { Write-Host "Error Start-Process: $($_.Exception.Message)" Write-Host "Press Enter to Exit." Read-Host exit } # Check, if EmbyServer started Write-Host "Check EmbyServer Status" $serverRunning = Test-EmbyServerRunning if ($serverRunning) { Write-Host "Successful: EmbyServer is running. Skript Exit in 3 Seconds." Start-Sleep -Seconds 3 exit } else { Write-Host "EmbyServer did not start." Write-Host "Press Enter to Exit." Read-Host exit } Voilá. EmbyServer works after system boot and works with embytray after logging in. No guarantees if it works for you, too. But i hope so. Edited May 27, 2024 by letterman 1
visproduction 315 Posted May 29, 2024 Posted May 29, 2024 Letterman, Try shutting down Windows differently. Use [Windows Key X], type U two times to shut Windows completely down. I am guessing that your shutdown is putting Windows in sleep mode. There are also bugs related to this where the workstation gets stuck in a Sleep mode sequence. To get out of that, you can restart and then hold the off button on startup so the computer forces a shut down. If you do that twice, you should get a Safe boot mode. There are many posts online discussing similar issues: https://duckduckgo.com/?q=windows+sleep+mode+error+cannot+shut+down&ia=web Hopefully when you start up correctly, Emby will begin to start automatically again.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now