mparadiso 0 Posted February 12, 2016 Posted February 12, 2016 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?
d00zah 143 Posted February 12, 2016 Posted February 12, 2016 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 KC:\Users\Media-PC>TASKKILL /IM MediaBrowser.Server* /T /FSUCCESS: The process with PID 1812 (child process of PID 2720) has been terminated.
jhoff80 93 Posted February 12, 2016 Posted February 12, 2016 If you're running as a Windows service, "net stop emby" and "net start emby" will stop and start.
Deathsquirrel 744 Posted February 12, 2016 Posted February 12, 2016 Do you want to start and stop the server or a client app?
mparadiso 0 Posted February 17, 2016 Author Posted February 17, 2016 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.
FrostByte 5257 Posted February 17, 2016 Posted February 17, 2016 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}" 3
mparadiso 0 Posted February 19, 2016 Author Posted February 19, 2016 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.
Koleckai Silvestri 1151 Posted February 19, 2016 Posted February 19, 2016 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. 1
pmathbliss 0 Posted July 14, 2019 Posted July 14, 2019 The swagger documentation is way better now. If you have curl in your path, curl -X POST "http://localhost:8096/emby/System/Restart?api_key=YOURAPIKEY"-H "accept: */*" -d "test=1" I had to add the -d "test=1" I had to add the -d "test=1"
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