Windows Script Host VBscripting

October 1st, 2004

Before I begin, if anyone is interested, I start my new part-time job today working at an elementary school for The Mohawk Regional School District.

Lately I’ve been diving deeper into the world of Windows, I generally stick to my comfortable, stable, and virus free OS X, but once in a while (much more than before since my new job will be 99% windows work) I delve into the inner workings of a Windows machine. Lately it has been Windows Script Host, or WSH.

I’ve been working on a project that never seems to go away. Not that I didn’t finish the project, but it involves backing up a computer. Something I should do way more diligently and often. So the basic idea here was that the computer was usually backed up every evening onto a CD. Only 200 MB of data needed to be saved at any given time, but that’s some 313 CD’s a year (no Sunday backup.) And really only the past day or two needed t be saved. So along I come, and thinking there must be an equivalent to AppleScript for PC, I thought this would be an easy job. To tell the truth, copying the data wasn’t really that hard, writing the log got messy.

Network issues aside (this was a wireless connection to get the data out of the building) the basic concept was to use Windows Explorer and Scheduled Tasks to move the data to another machine each morning at 2:00 AM. After dinking around for a while with the Backup Utility I decided to go with WSH as it would give me a usable backup. With the backup utility everything is placed in one archive file and can’t be used unless it is restored.

WSH can mount a file server, but I thought it might be nicer to pass this job off to XP, so I mapped a drive and had it re-connect at login (Windows calls it Logon?) Then I simply copied the contents of the folder to be backed up over to this new drive. Voila! It worked, sort-of . . . as long as the network was up. So back to fixing the network. . . And then, the great idea that took 2 or 3 times as long to implement. A log file. To cut to the chase, I wanted the log file written in reverse chronological order so the newest information would be at the top. This requires more work than it should. It seems to me Perl can do this in it’s sleep (correct me if I’m wrong.) Any way, after lots of grammar errors and a temp file I got it all working, and wish to share the fruits of my labor with all of you. Except you’ll have to wait, because I left the final version of the other computer and haven’t backed it up yet. Ooops.

One final comment, then hopefully later today I’ll post that script, though I better preface it with this note:

Use the script at your own risk, the code is not pretty . . . yet, but I’ll work on it eventually (or not.) It works for me, if it erases all of your files, they are gone.

Oh yeah, it keeps two backups of whatever directory you send it, so that if it stops in the middle of a backup you still have the previous.

So now onto my current Beef with Windows file sharing. . . .
Can someone explain to me why I can connect to an XP share with OS X without a password . . . OR USERNAME?!!!??! Hello security risk! With XP to XP it behaves okay, though both machines have the same user account so I guess I don’t really know if it is using a password scheme. But with my Mac I’m in like Flynn! I just don’t get it, commmon Redmond, lets get this thing locked down tight.

Okay, enough already, and this should be long enough to push my previous post so that it doesn’t run into my navigation. If anyone knows a quick and dirty fix for removing Safari’s cache permanently (that doesn’t involve installing an application, I’d love to hear it, because last I checked that wasn’t sticking out the right side of the middle section.