xboxscene.org forums

Author Topic: Shutting Down The Computer Your Streaming From  (Read 116 times)

Dunks

  • Archived User
  • Newbie
  • *
  • Posts: 12
Shutting Down The Computer Your Streaming From
« on: March 30, 2005, 10:56:00 PM »

Is there a script to allow you to shutdown/reset the computer your streaming video from, or a number of computers from the xbox?

I know this is possible from computer to computer....I have a vbscript that allows me to do this, can post the code from work tomorrow

The code I have only works from remote computers if they are part of the same domain, I'm guessing you'd have to pass and l/p to the computers that are being shut down before the computer will accept the shutdown/reboot msg.

I'm sure you could apply this in other area's of the xbox, but XBMC makes the most sence to have this feature.
Logged

dchurch

  • Archived User
  • Newbie
  • *
  • Posts: 23
Shutting Down The Computer Your Streaming From
« Reply #1 on: March 31, 2005, 05:00:00 AM »

Presumably the VB script uses an internal WinNT call somehow?

I have written the same application in the past in VB6 using an API call to shutdown/reboot other NT based PC's on a network.

If your script works in the same way then this would not work from XBMC.

What you would need to do is (IMHO) is to write a small TCP/IP listener program and possibly run it as a service on the machine you're streaming from so that it starts up invisibly each time the machine is on, then write a python script for XBMC that sends a message to the listener when you open it, or click a button or something.

When the listener receives the message, and makes all the relevant handshakes etc... it could then execute the API call (or however it does the shutdown) to shut the machine down.

That's what I would do.  Hope it helps.
Logged

Dunks

  • Archived User
  • Newbie
  • *
  • Posts: 12
Shutting Down The Computer Your Streaming From
« Reply #2 on: March 31, 2005, 07:18:00 AM »

makes sence, but don't know Python
Logged

dchurch

  • Archived User
  • Newbie
  • *
  • Posts: 23
Shutting Down The Computer Your Streaming From
« Reply #3 on: March 31, 2005, 07:44:00 AM »

I could probably give you some python code that would send the message to the listener.

It would have to wait until after this coming weekend though, as I am away until next Tuesday, and am at work at the moment.

Logged

dchurch

  • Archived User
  • Newbie
  • *
  • Posts: 23
Shutting Down The Computer Your Streaming From
« Reply #4 on: March 31, 2005, 07:59:00 AM »

In fact, if you have .net, here is some code for shutting down/ rebooting etc... (vb.net).

http://www.gotdotnet.com/Community/UserSam...ec-4a9a89d47fad

It is very similar to the prog. I wrote some years ago in VB6, the API calls are the same.

You will have to write the tcp/ip listener though, but again, if you are not a programmer I can probably help you there too.

This post has been edited by dchurch: Mar 31 2005, 04:11 PM
Logged

Dunks

  • Archived User
  • Newbie
  • *
  • Posts: 12
Shutting Down The Computer Your Streaming From
« Reply #5 on: March 31, 2005, 08:31:00 AM »

QUOTE(dchurch @ Mar 31 2005, 10:59 AM)
In fact, if you have .net, here is some code for shutting down/ rebooting etc... (vb.net).

http://www.gotdotnet.com/Community/UserSam...ec-4a9a89d47fad

It is very similar to the prog. I wrote some years ago in VB6, the API calls are the same.

You will have to write the tcp/ip listener though, but again, if you are not a programmer I can probably help you there too.
*



will try righting the vbp app, but would need help with the python script
Logged

dchurch

  • Archived User
  • Newbie
  • *
  • Posts: 23
Shutting Down The Computer Your Streaming From
« Reply #6 on: March 31, 2005, 08:49:00 AM »

Ok mate, no problem.

If I get a chance tonight I will write a little python script that sends the message via TCP to a listener on a given IP address/port, although tonight is going to be busy for me, so it will more than likely be next week.

Sorry for the delay but I'm going away until Tuesday (I might be able to sneak the laptop on holiday with me, but my girlfriend might get a bit upset :-)).
Logged

Dunks

  • Archived User
  • Newbie
  • *
  • Posts: 12
Shutting Down The Computer Your Streaming From
« Reply #7 on: March 31, 2005, 09:04:00 AM »

thats not problem

I've got a full plate myself

may take me a bit to my vb stuff.

Logged

dchurch

  • Archived User
  • Newbie
  • *
  • Posts: 23
Shutting Down The Computer Your Streaming From
« Reply #8 on: March 31, 2005, 09:13:00 AM »

Just out of interest, what do you want the script for?

Is it so that after watching a movie, you can just have one click to shut everything off?
Logged

jrl2222

  • Archived User
  • Full Member
  • *
  • Posts: 142
Shutting Down The Computer Your Streaming From
« Reply #9 on: March 31, 2005, 11:13:00 AM »

I think this would be very useful for alot of people. If your like me then the computer I am streaming movies from is in a different location then the xbox. Now I suppose I could get off my lazy but after watching a movie and walk to the part of the house that the computer is in to turn it off but then if you could just run a script to turn it off why use the extra energy.
Couch potatoes will rules the world one day when everything can be controlled from a remote or in this case and Xbox controller!!!!!!!
 :evil:

This post has been edited by jrl2222: Mar 31 2005, 07:13 PM
Logged

Dunks

  • Archived User
  • Newbie
  • *
  • Posts: 12
Shutting Down The Computer Your Streaming From
« Reply #10 on: March 31, 2005, 01:47:00 PM »

QUOTE(dchurch @ Mar 31 2005, 12:13 PM)
Just out of interest, what do you want the script for?

Is it so that after watching a movie, you can just have one click to shut everything off?
*



Thats pretty much it.

Its nice if your computer is in the another room/floor.

Logged

dchurch

  • Archived User
  • Newbie
  • *
  • Posts: 23
Shutting Down The Computer Your Streaming From
« Reply #11 on: April 01, 2005, 12:37:00 AM »

Yep, fair enough.

Couch spuds rule!!

Here's a script I have just knocked up - it's untested I'm afraid, as I am literally being dragged out of the door at this moment to go on holiday, but here it is:

CODE

import  xbmcgui, xbmc
from re import search, DOTALL
from string import split, replace
from os.path import getsize
from socket import *

# GET ACTIONCODES FROM KEYMAP.XML
ACTION_SELECT_ITEM = 7

# THE PATH TO BACKGROUND IMAGE
background = "q:\\scripts\\shutdownremote\\background.png"

s = socket(AF_INET, SOCK_STREAM)

class CShutdown:
   def __init__(self):
  self.addControl(xbmcgui.ControlImage(0,0,800,600, background))  
  self.strActionInfo = xbmcgui.ControlLabel(240, 200, 200, 200, '', 'font13', '0xFFFFFF99')
  self.addControl(self.strActionInfo)
  self.strActionInfo.setLabel('Clicking [OK] will send message')
   def onAction(self, action):
  if action == ACTION_SELECT_ITEM:
            # put the ip address of the listener in here.
            # make the listener listen on port 8100, and wait for a msg
            # that says 'shutdown'.
     s.connect(('192.168.1.200', 8100))
     s.send('shutdown\r\n')     
  if action == ACTION_PREVIOUS_MENU:
     self.close()
     
shutmedown = CShutdown()
shutmedown.doModal()


Save the file as something like 'shutdownremote.py' and put it in your scripts dir.

Also, shove a background.png image in your "scripts\\shutdownremote" folder for the background to work. (create the folders if they don't exist!)

Don't forget, Python uses indentation to determin the start/end of blocks - this might need reformatting.

If it doesn't work, post it in the Python Scripting forum, as it will just be that I have missed something silly.
If no-one can fix it by the time I get back, then I will do it.  It may, however, just work fine :-)

Good luck.
Logged