Archive for April, 2007

LiveWriter + SyncToy

Well I started blogging here about half a year ago primarily because I had quit a very bad-fitting job and started to pursue other work; my blog was intended to help me refocus on my hard skills set and also put a little bit out on display. I didn’t get very far at all, though, just about three weeks or so, before I found an almost dream job. No job is perfect but my current job now is still the best job I’ve ever had, hence no real need to be a show-off (or a wannabe, for that matter).

But I also started blogging here to dump tech thoughts. And that’s the more "pure" reason for blogging anyway, one that motivated me almost equally.

I was using LiveWriter here. No, not PowerBlog, which I built by myself over the course of two or three years and now, two years after having walked away, I look at it with a cringe and a blush. Recently I fired up the PowerBlog source code in Visual Studio on Windows Vista. Crash, bang, boom, I spent at least a couple hours trying to refactor naming convention clashes (like "WebBrowser", which also showed up in System.Windows.Forms in .NET 2.0) and other issues, but ultimately I couldn’t win. R.I.P., PowerBlog v2. Maybe I’ll rewrite you from scratch someday, a v3, in .NET v3.

But LiveWriter is a cleaner version of what PowerBlog tried to be. It lacks a lot of features PowerBlog had, like a grid list of all posts not unlike Outlook Express (indeed Outlook Express was a huge design inspiration for PowerBlog), but LW has something PB didn’t have and that I had always planned to add but never even started: image insertion and management. LW took a step further and applied automatic resizing and effects. Great. I like it.

I guess what stalled the blog here was the fact that I got a laptop, but LiveWriter had been set up on my desktop PC, which served as a web server (for tinkering), a Windows XP Media Center Edition server for my XBox, and a file server for all my personal junk and backups from present time to years past. Later I got another computer, a dedicated gaming / music workstation for the living room, which took over my big 20" LCD screen. Now my "home server" had an old CRT and was being ignored in the back room not really doing much except serving recorded TV to my living room over the LAN.

I could have installed LiveWriter on my laptop, and in fact I did, but I discovered that my drafts were not kept on the server. I’d have to synchronize the drafts. And I didn’t figure it was worth the time to mess with it, and that I should just sit down at the "back room PC" if I want to blog.

Never happened. Very recently I tried Remote Desktop, but LiveWriter has an almost fatal incompatibility with Remote Desktop: it invalidates the entire screen (causes the screen to re-paint itself) with every keystroke, which means that for every letter typed into Live Writer I would have to watch the screen go blank for a split second. A-[blink]-n-[blink]-n-[blink]-o-[blink]-y-[blink]-i-[blink]-n-[blink]-g-[blink]-!-[blink]

So now some months have passed sinced I was really blogging and I’ve been queuing up a lot of things, mostly small, that I would have liked to have blogged about, even if only a brief mention. Not long ago, I upgraded my back room home server to Windows Vista, with a fresh installation, giving me a clean slate. So today I finally sat down and came up with a solution.

The problem: I have three computers, and would like to blog using any one of them. I don’t want to blog using a web interface, I prefer to use a Windows application. But I also want my drafts and post history to be kept in that windows app. PowerBlog handled this, but it was so permanently alpha I would not bother to attempt using it. LiveWriter is good enough, although at some point I want to post code blocks and LiveWriter is too limited at formatting options

The solution was to synchronize my three machines for LiveWriter drafts and history. Fortunately, the Drafts and post history of Live Writer are kept as flat files in the user profile directory. Since all three computers are running Vista, all three keep their LiveWriter files here: C:\Users\Jon\Documents\My Weblog Posts. I could just edit the registry and point LiveWriter to use \\mediacenter\c$\Users\Jon\Documents\My Weblog Posts as the application "home" directory, but I thought that would be too severe and prone to too much LAN chatter. I thought about using a tool I had written that used .NET’s FileSystemWatcher to synchronize files, but decided it was too much trouble and doesn’t take into account file changes while one or the other computer is shut down or offline. I could xcopy the files with a batch file, but Microsoft SyncToy seemed to be a better quick solution, for ease of implementation. Robocopy would have done just as well as SyncToy, I suppose, but I thought of SyncToy first.

On both of my living room computers (the gaming / music workstation, and the laptop) I pointed SyncToy to C:\Users\Jon\Documents\My Weblog Posts as the left directory, and to \\mediacenter\c$\Users\Jon\Documents\My Weblog Posts as the right directory, with the synchronization type flag set to Synchronize.

Then on both computers I created a SyncAndRun.bat file:

"C:\Users\Jon\AppData\Local\SyncToy\SyncToy.exe" -R
"C:\Program Files\Windows Live Writer\WindowsLiveWriter.exe"
"C:\Users\Jon\AppData\Local\SyncToy\SyncToy.exe" -R

This essentially synchronizes to catch up my blog posts, then runs Live Writer so I can do my blog thing, then synchronizes again to push out any blog changes.

Then I dragged a shortcut to the .bat file to my Quick Launch toolbar. I changed the shortcut icon to use the WindowsLiveWriter.exe icon, and changed the shortcut file name to "Synchronize and Run Windows Live Writer".

There! 🙂 Now everything is perfect. I can hop onto any of my three home computers and start blogging away. Everything will be in place.

Categories: Pet Projects