11 December 2007

A better http icon for your users

At the client we have been giving direct shortcuts to web application which sometimes require many different icons. The problem is that the default Windows icons for web shortcuts are very limited.

The solution is to point the icon variable to the shell32 dll, which will give you (and the user) a bit more variety.

The process is as follows:

1. Create the shortcut by right-clicking the desktop and choosing the location.
2. After naming and testing the shortcut, right-click on the shortcut and choose 'Properties'.
3. From the shortcut tab, push the 'Change icon' button.
4. In the browse window, browse to the following path: %SystemRoot%\system32\SHELL32.dll (or copy/paste the path given here).

Windows provides many more options from this dll.

Remove that pesky Windows Service

I have been writing a Windows Service (no easy feat, let me tell you) in Visual Studio and have found that getting it off the machine is just as difficult.

Following is a batch file to remove the service in question. The process is as follows: Use Add/Remove programs to get rid of the service, then run this batch file. One word of warning, the machine needs to be rebooted in order to remove the service.

VB Script File

On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
strKeyPath1 = "SYSTEM\ControlSet001\Services\[ServiceName]"
strKeyPath2 = "SYSTEM\ControlSet001\Services\Eventlog\Application\[ServiceName]"
strKeyPath3 = "SYSTEM\ControlSet002\Services\[ServiceName]"
strKeyPath4 = "SYSTEM\ControlSet002\Services\EventLog\Application\[ServiceName]"
strKeyPath5 = "SYSTEM\CurrentControlSet\Services\EventLog\Application\[ServiceName]"
strKeyPath6 = "SYSTEM\ControlSet001\Services\Eventlog\Application\[ServiceName].[ServiceName]"
strKeyPath7 = "SYSTEM\ControlSet002\Services\Eventlog\Application\[ServiceName].[ServiceName]"
strKeyPath8 = "SYSTEM\CurrentControlSet\Services\Eventlog\Application\[ServiceName].[ServiceName]"

Set objRegistry = GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")

DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath1
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath2
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath3
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath4
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath5
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath6
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath7
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath8

Set WSHShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"

Sub DeleteSubkeys(HKEY_LOCAL_MACHINE, strKeyPath)
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys

If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubkey
End If

objRegistry.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath
End Sub