Monthly Archive for January, 2008

Vista: Run a script at shutdown

I wanted to configure my Vista Home Premium machine to run a script at shutdown, to synchronise "My Documents" to my file server. On my old XP workstation this was done by editing the local group policy and specifying a shutdown script, and then configuring PathSync (a nice free app) to sync the files to a remote location. The challenge this time is there is no local group policy editor on Vista Home premium.

Options
1. Install some software that modifies the shutdown routine
I didn't really want to do this. I've only had this machine a few weeks and want to keep it free of software that could mess things up. I also don't want to pay for a solution, if possible.

2. Windows registry editing
Every local group policy has a corresponding registry entry, so I wondered if in the absence of the group policy editor, I would just be able to create the relevant registry keys and values to run a script at shutdown. Microsoft kindly provide a list of group policies and where they are configured in the registry, so I downloaded it to have a look. Sadly I couldn't find what I needed in here.

I also wondered if I would just be able to export the existing key from my XP machine into Vista, I tried this but that didn't work either - looks like this was because it references the name of a local group policy, which of course didn't exist on my new machine.

3. Windows task scheduler
The Vista task scheduler is actually very good. You can schedule tasks to run when specific events are written to the event log, such as Event 4634 in the security log (Log Off). I tested and found this would actually work if I used the log off feature, but when shutting down, the OS does not wait for scheduled tasks to finish so it only gets to run for a few seconds.

4. Use a VBScript to sync and shutdown
This is how I've implemented this solution - for now. I've created a VB Script which brings up an "Are you sure you want to shutdown" dialog, if you click yes, it syncs to my remote machine and then shuts down. Then I created a shortcut to the script and added it to the quick launch buttons, next to the start menu button. As a final touch I changed the icon to the same power icon that Vista uses for shutdown.

Shutdown icon
Shutdown button

The snag is of course you have to remember to click on this button to shutdown if you want your documents to sync, if you forget and use the usual shutdown option on the start menu, you get no backup for that session. This also means that it doesn't sync when you reboot, and you also don't get the option to install Windows updates before the computer shuts down.

Anyway here is the script:

Set objShell = CreateObject("Wscript.Shell")
Set wshShell = WScript.CreateObject ("WSCript.shell")
strShutdown = "shutdown -s -t 0 -f"

Continue = MsgBox ("Are you sure you want to shutdown?",vbYesNo + VBCritical, "Shutdown computer")

If Continue = vbNo then

' Do nothing

Else

' This box will disappear after 5 seconds.
intReturn = objShell.Popup("The computer will now sync and shutdown.", 5, "Shutdown computer", VBInformation)

' Run synctoy - just change "MyDocs" to the name of your folder pair.
wshshell.run """c:Program FilesSyncToy 2.0 BetaSyncToyCmd.exe"" -RMyDocs", 6, True

' Shutdown the computer
objShell.Run strShutdown

End If

One slight annoyance is the SyncToy command prompt window opens minimised, but I can live with that for the moment. I tried a number of sync tools before settling with MS SyncToy. I did try using rsync which I thought may be a bit faster due to it's compatibility with Linux, but the scanning of the folders took forever.

Technorati Tags: , ,

Cheating with ESX Server Starter Edition

ESX Starter Edition is a standalone ESX server (i.e. no Virtual Centre), available at a lower cost than the ESX Infrastructure editions but missing some useful functions. Some of those functions are the ability to convert virtual machines to templates simply by right-clicking on them, and deploying VM templates with a single mouse click. With the Starter Edition this is how you can get around it:

Create template
Install and configure your virtual machine exactly how you want it. Give it a generic name like "TEMPLATE" and leave it in a workgroup. If your template is a Windows 2003 server "sysprep it" by following this article. Power your VM down and your template is now ready.

Deploy the template
This is how it works:

  • Create a new Windows 2003 VM, configure the disk to be as small as possible
  • After creation, edit the VM settings and delete the disk
  • Open an SSH session to the ESX server using Putty
    • cd /vmfs/volumes/ESXservername\ storage/TEMPLATE
  • Copy the VM disk to the new machine:
    • cp *.vmdk ../new_server_name
  • In VIC, edit the settings of the VM, add a new disk, point it to /storage/new_server_name/disk_file.vmdk
  • Boot the VM up run through sysprep
  • Let it run for about five minutes while sysprep takes place, set computer name and NIC details etc when prompted
  • The server will then restart.
  • The server is now ready and just needs to be joined to the domain.

The whole process should take no longer than half an hour.

Technorati Tags: ,

Vista backup is stupid.

I've been trying to get Vista to backup files to another computer on the network, and it's just not having it.

The remote machine is a Linux computer on the network. If I click open the Vista menu, and then type \\servername\backups, it opens straight away and I can drop files in there and do whatever I like in the remote location.

But, when I use "Backup status and configuration" to set up a new backup job and set the remote location to "\\servername\backups", first it asks for a password (which I enter - this is the Unix password for user Ben), then I get this message:

Error Message
Vista doesn't like Samba?

But that's not the end of it. If I then go back to my remote backup location, I can see a new file in there called SDT97DB.tmp and a folder with a randomly generated name - so, it clearly can access that location as it has created folders and files there!!

Not sure if this is a bug with Vista or a compatibility issue with Samba but it's damn annoying!

Technorati Tags: , ,