Your Digital Media Has Never Looked So Good

 
tjdebon
Topic Author
Posts: 111
Joined: Mon May 09, 2005 4:47 pm

How do I execute a batch file on my WinXP PC from PB?

Wed May 16, 2007 10:54 pm

I finally got to the root of my SlimRoku problems. The recurrent SlimServer stoppages and SlimRoku hangs were not due to my WLAN (in fact a HomeLink 2.0 compliant powerline network had worse dropouts), I've had many of the same problem using wired LAN with a 50 foot cable strung across the kitchen and family room floor.

My Sony VAIO PC has a proprietary UPnP server that upsets SlimServer. I can stop the VAIO UPnP when I want to listen to SlimRoku iff I can launch a bat file on the PC from the PB, and then restart it again when I turn off SlimRoku.
Someone must have figured out how to launch a batch file on the PC from a script on the Roku, if so, please post a sample script that can execute a .bat on the Win XP PC.

Thanks in advance!
 
soiaf
Posts: 785
Joined: Fri Jan 14, 2005 5:19 am

Thu May 17, 2007 2:23 am

I haven't tried this, but I think you'd be able to do this using netcat on the PC
http://www.vulnwatch.org/netcat/

If you look at the readme you'll see that you can use it to launch programs e.g.

A far more exciting thing to do is to get a quick shell going on a remote
machine by using the -l or "listen" option and the -e or "execute"
option. You run Netcat listening on particular port for a connection.
When a connection is made, Netcat executes the program of your choice
and connects the stdin and stdout of the program to the network connection.

nc -l -p 23 -t -e cmd.exe


If you also have netcat compiled on the Roku you could use it to send commands to your PC (so netcat on PC, netcat on PhotoBridge).

I could try this out over the weekend if you're interested.
 
soiaf
Posts: 785
Joined: Fri Jan 14, 2005 5:19 am

Fri May 18, 2007 1:30 pm

Ok, I had a go and I got it working.
Perhaps not the most elegant solution but very powerful, you can run pretty much any program on your PC from your PhotoBridge. I suppose if your PC controls anything else like lighting, air conditioning etc. they could also be triggered from your PhotoBridge.

1) Download netcat for the PC
http://www.vulnwatch.org/netcat/nc111nt.zip

Note the Norton Antivirus tries to flag this as a virus. It isn't! See more details on the netcat website http://www.vulnwatch.org/netcat/

2) Download the following zip file I put together
http://members.upc.ie/p.mc.quillan/netcatplusapps.zip

3) Unzip 'my' zip file (from step 2) and store in the root directory of a compact flash card

4) Unzip the PC netcat application

5) Start a command shell on your PC (do this by going to 'Run' in the start menu and typing cmd ). Go to the directory you unzipped the netcat application and start the PC netcat application

nc -L -p 75 -e cmd.exe


The number 75 in this case is the port you want this application to listen on. 75 is generally not used, so I went for that. But you can choose any port that you like (as long as its not already used obviously).

Note that your firewall may pop up a warning at this stage, so allow the application to have port access.

Thats it set up. You can put the command in step 5 into a BAT file which you could have your PC automatically start at bootup by putting in the Startup folder of your PC.

Now if you want to run a command on your PC, you'll see that one of the files on the compact flash card (that you can see on the PhotoBridge main menu) is called runpcjob

Theres not much to this file (runpcjob.roku) - it contains the following

cat /mnt/flash1/mycommands.txt | /mnt/flash1/nc110/nc -t -w 5 10.1.1.40 75


What this is doing is it is using the PhotoBridge version of netcat (which I ported over and added to the package you downloaded) to connect to port 75 of your computer (in my case my computer has an IP address of 10.1.1.40). The 5 after the w flag is a timeout wait, so everything runs and then tidies up after itself. The file mycommands.txt contains the commands you want to run on your PC - this is the file you want to edit.

In my case mycommands.txt doesn't contain much of interest. However notice that my first line is empty and that there is an empty/blank line after every command (including the last). Each line in this file is basically a command you want to run on your PC.
In your case this is probably the command line needed to stop/start the UPnP server.
I used a copy file command in my test file as this is a good way to see that everything is working as expected.

Hopefully this should work for you relatively painlessly, but let me know if you need any more help.
Last edited by soiaf on Wed Jun 06, 2007 12:41 pm, edited 1 time in total.
 
soiaf
Posts: 785
Joined: Fri Jan 14, 2005 5:19 am

Sat May 19, 2007 1:36 pm

So I've thought of a completely different way of doing this.

1) Write a tiny script for the PhotoBridge that creates a file in a network share on the PC.
2) Call this script when you want a particular action to occur.
3) Have a BAT file running on your PC checking for the existence of this file, and if its there call your 'main' BAT file

The code for the monitoring BAT file on your PC would be something like this:

@ECHO OFF
REM checkfile.bat
REM Checks every 30 seconds for a certain file to exist. If the file exists, it calls an
REM external BAT file, deletes the trigger file and resumes its 30 second check

:MYMAINLOOP

REM Change the filename to whatever filename you like to check for
REM We use the CALL command as this returns the flow of command back to this script
REM when the BAT file we call has finished

IF NOT EXIST c:\storage\filecheck.txt GOTO SLEEPSECTION

CALL c:\storage\myaction.bat

DEL c:\storage\filecheck.txt


REM There does not seem to be a sleep command avaiable, the following is a hack that
REM emulates a sleep. The number after the n (minus 1) is the number of seconds delay we want

:SLEEPSECTION

ping -n 31 127.0.0.1>nul

GOTO MYMAINLOOP


The code in the BAT file is definitely not perfect, but should do the trick - its an infinite loop with a check every 30 seconds or so, if it finds the magic file it calls an external BAT file and then deletes the magic file.

The problem with this solution is that its not as flexible as the first solution I gave, but should be ok if theres only a limited number of things you want to do.
 
soiaf
Posts: 785
Joined: Fri Jan 14, 2005 5:19 am

Mon Jun 04, 2007 5:05 am

Another way to do this is with VNC. VNC allows you to see your computer desktop on another computer (or in our case the HD1000).
If you use VncSix on your HD1000, with a VNC server running on your PC, you'd be able to navigate your computer desktop and select the BAT file to run yourself.

More details about VncSix here: http://frequal.com/roku/VncSix/index.html
 
Burkhardi
Posts: 1943
Joined: Tue Jun 07, 2005 11:06 am
Location: Austin, Texas ...Y'all

Re: How do I execute a batch file on my WinXP PC from PB?

Mon Jun 04, 2007 5:58 am

tjdebon wrote:
I finally got to the root of my SlimRoku problems. The recurrent SlimServer stoppages and SlimRoku hangs were not due to my WLAN (in fact a HomeLink 2.0 compliant powerline network had worse dropouts), I've had many of the same problem using wired LAN with a 50 foot cable strung across the kitchen and family room floor.

My Sony VAIO PC has a proprietary UPnP server that upsets SlimServer. I can stop the VAIO UPnP when I want to listen to SlimRoku iff I can launch a bat file on the PC from the PB, and then restart it again when I turn off SlimRoku.
Someone must have figured out how to launch a batch file on the PC from a script on the Roku, if so, please post a sample script that can execute a .bat on the Win XP PC.

Thanks in advance!


So there is a UPnP server on your VAIO that kills SlimServer? If so, try using the switch --noupnp

If this is the case, let me know and I'll expand my reply.
Regards, Matt
Roku3 and Roku HD1000 [Rev B] on a Samsung HLP5674W DLP in the living room; a Roku2 and two Roku XS and a few SoundBridges.Win7; Kubuntu and XP via RT-N66U, E2000 and a switch or two. I own stock in Roku, it's just all in the form of hardware.Viva la Roku
 
andy
Posts: 229
Joined: Mon Aug 23, 2004 7:54 pm
Contact:

Mon Jun 04, 2007 8:49 pm

soiaf wrote:
If you use VncSix on your HD1000, with a VNC server running on your PC, you'd be able to navigate your computer desktop and select the BAT file to run yourself.

More details about VncSix here: http://frequal.com/roku/VncSix/index.html

Thanks for mentioning VncSix! If there are any questions about it please post them here. It has two navigation modes (toggled using the 'fast forward' button. In one mode the direction buttons move the mouse, in the other they send arrow presses. This makes it easy to switch between doing something with the mouse and moving around a list of items like icons or menus.

-Andy
Andy Oliver
LiveSpy: Watch Live Webcams:http://frequal.com/LiveSpy/roku/index.html
VncSix: Web Surfing+:http://frequal.com/roku/VncSix/index.html
SongInfo:http://frequal.com/roku/SongInfo/index.html
 
tjdebon
Topic Author
Posts: 111
Joined: Mon May 09, 2005 4:47 pm

Thu Jun 07, 2007 10:25 pm

Thanks for the wonderful ideas. Between biz trips and houseguests (and family complaints that I spend too much time tinkering on the computer :oops: ) I haven't been able to get enough time with both the PC and the home theater to get something really going; got partway thru the netcat download. I'll probably go the infinite-loop batch job route (hacker intruder paranoia). I do have VncSix, it works very well -- just going for the "hit one button on the HT remote" approach. But my SlimServer problems (which were motivating the PC app launch effort) run a little bit deeper...

I did have flawless performance (~20hrs straight) launching SlimServer --noupnp in a command window on wired LAN with all the VAIO uPNP servers and related (or my best guess) services stopped; hence my plea for help launching a PC app.

But with wireless-LAN and SlimServer launched from the tray icon (without the -noupnp switch) I still occasionally (~ two hour intervals?) get the main song display screen to freeze and only the progress bar and LCD window update, even with all? the uPNP services stopped. No events are logged on the PC. I guess I need to be more careful about capturing SlimRoku debug files and documenting which song last successfully uupdated the display to get a clue what to do next.

Who is online

Users browsing this forum: No registered users and 2 guests