Jump to content

Is there a way to turn off the Emby through DOS command line?


mparadiso

Recommended Posts

mparadiso
I wonder if there is a way to turn off the Emby by DOS command line.

My idea is to create a bat file to perform this task. Like this, I can turn off the Emby through EventGhost by remote control for CEC device.

Someone informs me know if it's possible?

Link to comment
Share on other sites

d00zah

My initial installation predates the change from MediaBrowser to Emby so task name MAY differ...

 

C:\Users\Media-PC>TASKLIST /FI "imagename eq MediaBrowser*"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
MediaBrowser.ServerApplic     1812 Console                    1    383,828 K

C:\Users\Media-PC>TASKKILL /IM MediaBrowser.Server* /T /F
SUCCESS: The process with PID 1812 (child process of PID 2720) has been terminated.

Link to comment
Share on other sites

mparadiso

Hi,

 

I do not know if the solution I found would be possible. I could send the EventGhost an http command to turn off the Emby for my remote control. It is something similar to what is today Emby the browser.
Emby in the Server option, Dashboard tab there is an option called "Server Information" there are 2 buttons (Restart and Shutdown).
I could send the same command triggered by the Shutdown button at EventGhost and with it, turn off the Emby.
Could someone tell me if this is possible? When I do this, the request is sent via post, and I have no way of knowing that action was triggered.
 
Thank you.
Link to comment
Share on other sites

FrostByte

You can do it with a batch file and PowerShell.  Code should look something like this, just place the two files in the same folder and make sure they have the same filename

 

CloseEmby.ps1

#Test for admin permissions
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{   
#"No Administrative rights, it will display a popup window asking user for Admin rights"

$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments

break
}

$ProcessName = 'MediaBrowser.ServerApplication'

#Close emby
write-host "Closing emby"
Stop-Process -Name $ProcessName -ErrorAction SilentlyContinue -Force
Wait-Process -Name $ProcessName -ErrorAction SilentlyContinue

#Complete
write-host "Emby closed"

CloseEmby.bat

@ECHO OFF
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"
  • Like 3
Link to comment
Share on other sites

mparadiso

 

You can do it with a batch file and PowerShell.  Code should look something like this, just place the two files in the same folder and make sure they have the same filename

 

CloseEmby.ps1

#Test for admin permissions
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{   
#"No Administrative rights, it will display a popup window asking user for Admin rights"

$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments

break
}

$ProcessName = 'MediaBrowser.ServerApplication'

#Close emby
write-host "Closing emby"
Stop-Process -Name $ProcessName -ErrorAction SilentlyContinue -Force
Wait-Process -Name $ProcessName -ErrorAction SilentlyContinue

#Complete
write-host "Emby closed"

CloseEmby.bat

@ECHO OFF
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"

Like the proposed solution. But is there any way to do this using HTTP command? It would be the same as the Emby do when we press the button off the browser.

Link to comment
Share on other sites

Koleckai Silvestri

Like the proposed solution. But is there any way to do this using HTTP command? It would be the same as the Emby do when we press the button off the browser.

Not as easily. The API that would shut Emby down requires a POST request, i.e. a form submission. What you get from a web browser address bar is a GET request. You could build a page and replicate the shutdown button. You would have to deal with user and device authorization to make it work. Simpler just to load the Server Dashboard and click the existing button. 

 

You can look at the API by clicking API in the footer of the server dashboard. It takes about 5 minutes to load in Firefox. Once loaded, scroll down the emby object and expand it. You'll find the shutdown command under emby/emby/System/Shutdown. 

  • Like 1
Link to comment
Share on other sites

  • 3 years later...

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...