Starting Tracks in a Hidden Window

[?]

You may remember, about a month ago, I wrote for installing the GTD application, Tracks, under Windows. The only flaw with the program was that the command prompt window remained open while you were using the application (which is web-based). Thanks to one of my readers (who, unfortunately, didn’t include a link with his comment), I’ve figured out how to start Tracks in a hidden window. It involves a little code hacking, but it works quite well, and a simple .bat file will allow you to start it on login.

Okay, it’s a bit complex, so listen up.

First, open Notepad and paste the following into it:

Const HIDDEN_WINDOW = 12

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")

Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = HIDDEN_WINDOW
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create("ruby g:\tracks\script\server.rbw --environment=production", null, objConfig, intProcessID)

You need to change the portion that reads “ruby g:\tracks\script\server.rbw –environment=production” to read correct for where you installed Tracks.

Then, save the file and call it “tracks.vbs”.

Now, move the file to wherever you’d like to keep it (I keep it in my g:\tracks directory).

Now, create a new text document in notepad, and put the following into it:
cscript g:\tracks\tracks.vbs

Again, change the g:\tracks\tracks.vbs to reflect where you placed the tracks.vbs file.

Save the file as “tracks.bat”.

Now, you can double-click on “tracks.bat” and it will load Tracks into a hidden window. Give it about a minute or so, and you should be able to login at http://localhost:3000

To start tracks when you log in to Windows, you merely need to create a shortcut to the tracks.bat file in your startup folder on the start menu (or, you can do like me and place the actual tracks.bat in your startup folder).

To close/stop Tracks:
For Windows XP: open your task manager (CTRL-ALT-DEL), go to the “Processes” tab, find the line that says “Ruby”, click it once to highlight it, and click the “End Process” button. The system may throw you a warning that you can safely ignore.

For Windows NT/2000/2003: Hit CTRL-ALT-DEL, click the Task Manager (or Process Manager) button, find the process list and locate “Ruby.” Click it once to highlight it, click “End Process”.

For Windows 98/ME: Hit CTRL-ALT-DEL, Find “Ruby,” click to highlight, click “End Task”. If you can’t find Ruby on your Windows 98 task list, then upgrade to Windows XP. heh.

Enjoy Tracks when you start.

Technorati Tags: , ,

Help spread the love and Share This


4 Responses to “Starting Tracks in a Hidden Window”

  1. MindFyre » Blog Archive » Setting up Tracks under Windows XP says:

    [...] I’ve finally found a solution. Using Visual Basic Script, you can start ruby in a hidden window. Read this entry for all the details. Tags: gtd tracks tutorials mysql ruby [...]

  2. stipes says:

    It’s a good idea, but isn’t it a little overkill when you could just do:

    rubyw script/server -e production

    in a .bat file and put it in your startup folder?

    ~stipes

  3. ybgzmwojpc says:

    Hello! Good Site! Thanks you! vxwuyicciro

  4. hintveixih says:

    Thanks for this site!
    hifue.info

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>