Enumerating SQL Server instances on a remote Windows host

Programmatically enumerating a list of SQL Server instances from a remote Windows server can be challenging. If you have the Remote Registry activated, and know the name of the target server, you can fairly easily get the list of instance names from the server via the following VB code snippet.

This code does nothing other than print the list of remote instances to the console, however it could form a simple wrapper for any number of processes you need to perform on newly discovered SQL Server instances.