Archive for the ‘Cygwin’ Category

Shutting down Windows

Tuesday, May 1st, 2007

My kids like to play games on my personal laptop which happens to have WinXP Home on it. Of course they don’t like to get off it when it’s time for dinner, bed, bathing, school, … Going in there and making them shut it down can be a challenge.

So the solution a mash-up Apache and psshutdown now available from Microsoft. My apache was installed through cygwin so I have all the shell powers available for my cgi scripts.
Just make some cgi scripts and off we go.

You will need to make a dummy script to accept the licence using the /accepteula switch which needs to be run once or the scripts will just all fail.

I added the sysinternals tools to my system environment path so they will get picked up without addng the path.

Then the following script is dropped into

/srv/www/cgi-bin/shutdown

#!/bin/sh

# disable filename globbing
set -f

echo “Content-type: text/plain; charset=iso-8859-1″
echo
echo Force shutdown of computer
echo

psshutdown -kf

I also set up a static IP address for the laptop.

Now I just put a bookmark in my browser http://192.168.1.199/cgi-bin/shutdown and clicking on this shuts that laptop down without any arguments.

I have Wi-Fi capable mobile phone so put the bookmark in there and I can easily shut it down from there too, which is really handy as I’m not always in front of a computer screen.

Start

Friday, February 2nd, 2007

I like to use a command line interface whenever possible. Sometimes though a windowed application is required. In MS Windows you use the start command to bring up the default app, (don’t use this much). In Cygwin I use the cygstart command.

So I was using my Ubuntu system and wanted to do something similar. The command it turns out is gnome-open. Bit of a mouthful so I have this aliased in my .bashrc file to cs for either cygstart or gnome-open which is much more snappy.