Skip to content

Instantly share code, notes, and snippets.

@tommorris
Created July 11, 2009 18:10
Show Gist options
  • Save tommorris/145333 to your computer and use it in GitHub Desktop.
Save tommorris/145333 to your computer and use it in GitHub Desktop.
help me, Windows nerds!
I want to build a really simple script to use on Windows. I know
nothing about Windows programming.
Scenario:
I've got a shitty DSL line that doesn't have much bandwidth.
I want to prioritise certain applications. I've got some services
on my Linux box that I want to turn off when a user on a particular
Windows machine is running certain applications.
Plan:
I'd like to write a script that runs in Windows that monitors what
applications are running every so often and if certain apps *are*
running, it would trigger various commands which would be sent to
the Linux box.
I'm thinking of writing this in something like IronRuby.
Then all I'd have to do would be to poll the .NET framework's
System.Diagnostics.Process.GetProcesses() class method which
the documentation says should return an array of Process objects
which I could iterate through and match the title to the ProcessName
object property.
I was then planning to have it so that if it matches, the script
would trigger off a System.Net.HttpWebRequest instance to POST back
to the server a message saying that the app is running. Or maybe just
use the standard Ruby net/http class.
I'm hoping to deploy this to a Windows XP machine. I'm not sure
what version of .NET is running on the machine.
Questions:
1. Am I on the right track?
2. Is IronRuby a sensible choice (considering I use Ruby and JRuby
on Mac and Linux)? I can do IronPython if that's better. I haven't
really got time to learn C# or VB.NET, and I'd rather do this in
Vim than have to install Visual Studio on a borrowed Windows machine
(did I mention that I don't have a working Windows machine of my own?)
3. Is there already an app that would do this without me having to bother?
4. How do I package this up? Can I just have it floating around in, say,
C:\Documents and Settings\$username\script.rb (or whatever)?
5. What's the .NET equivalent of crontab? I want to be able to set this
script to run every, say, ten or fifteen minutes. How would I do that
in Windows.
Feel free to e-mail me any advice <[email protected]> or just 'fork'
this Gist. I'm rather looking forward to stepping outside my Mac/Linux
comfort zone and writing some code to run on Windows. And .NET looks like
it might not be a total trainwreck like the usual Windows stuff which I
am unfortunately familar with. ;) -tm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment