6to4

WQL, SQL Queries for Windows Backend (Part 1)

If you have been writing web apps for a while, or other apps you more than likely have used SQL. SQL allows you to query a database and interact with your applications data. Instead of trying to find a users profile, what if we wanted to find out what a user was printing on their local machine? If there was an easy interface for that, it could make programming for a platform like Windows a lot easier. Well Microsoft years ago added this ability to Windows; the technology is called WQL. This was added with the other components of WMI (Windows Management Instrumentation) at Windows ME. For Windows 9x and NT you can download the WMI core. This article will be a brief over view of what it can do and how you can play around with it.

First like when we looked at LDAP, we want a tool that will let us quickly play around with what is available, and then code that into our application. The tool I use is WMI Explorer, http://www.ks-soft.net/hostmon.eng/wmi/, it provides a easy interface to look at all the data available. With the WMI core it works with everything back to Windows 95! You can download and run the program for free, no installation required. Once open, there is a upper portion of the window that lists all the spaces you can access, these would be the ‘tables’ in SQL. Depending on your version of Windows, there will be separate options available. I have used this interface before for network cards (6to4 Cleaner) and printers.

WMI Explorer

WMI Explorer

For this example I will go over to the Win32 framework and access the Win32_Printer ‘table’. I get a list of printers the machine has installed, as well as attributes to each of these printers. Any administrator, or any program attempting to manager printers (I say attempting because printers can he a horrible experience) information – like what port the printer is using – is here, in addition what type of connection this machine has to the printer. At the bottom of the Window there is a Query that is building as you select different fields. This query can be moved into a application later to get the same data in code. WMI Explorer also allows for a user to write Queries directly without this interface; that is the second tab at the top of the window.

One downside I have found in using WMI is the setup process time, in C#/.NET using WMI is easy, but it takes time to start accepting queries. About a year or two ago I was working on querying network card information on Windows Vista. The first call could take a few seconds to respond, after that first call it would speed up, this is just something that has to be accounted for in the applications design. I found running WQL queries in a separate process, and starting them as soon as possible would allow the process to finish before the user needed the data.

I just wanted to get everyone started looking at what is available, in a later article I will go into more depth about programming with this and how you can interact with this data in a C#/.NET program.

6to4 Adapter Cleaner, v1.60

This version brings a few fixes and new features, hence the version jump. Features Include:

  • Minimize to Tray when removal is working
  • Checks if already running on startup
  • Faster IPv6 detection for method 2
  • Slightly smaller

 

Download:

https://github.com/daberkow/daberkow.github.io/tree/master/6to4CardCleaner

6to4 Card Cleaner v1.50, IPv6Activator v1.00

This new version of 6to4 Card Cleaner adds the full Microsoft process of fixing the problem; the program will disable IPv6, remove the cards, and then run KB980486. There still is a option to just remove the cards.  Added features also include an updater, a window that allows you to set IPv6 to any of the 6 settings, and a new backend.

These cards WILL NOT show up in device manager, unless you turn on hidden devices, and WILL NOT show up in ipconfig unless you do ipconfig /all.

I also took out the window that lets you change the IPv6 setting, and made it its own app, so if you need a user to just change IPv6 they can get this 70kb app.

As always any bugs please report them, I will patch and the automatic updater will alert users a new version is available. Source available on request.

Download

Main Program

https://github.com/daberkow/daberkow.github.io/tree/master/6to4CardCleaner

IPv6Activator

https://github.com/daberkow/daberkow.github.io/tree/master/IPv6Activator

6to4 Card Duplication

Multiple versions of Windows, mostly Windows 7, support IPv6 networking, and if your network doesn’t support it, and the machine wants to link to a site or computer that does, it will make a virtual IPv6 to IPv4 converter card. Now sometimes Windows doesn’t reuse them, or delete them. So in this situation these cards keep being added to the system, adding and adding. Eventually the use will attempt to connect to a local server, or some other service, and Windows will try every card first, and then fail to connect. Timing out even though the real connection has no fault. It appears at around 180 virtual cards we start to see this. The solution is removing all the cards, but Windows wants you to remove them one at a time. Microsoft does have a tool for removing devices in a systematic order, but you need to get the one for your architecture, and some of these need you to download a large package and extract it. So I decided to make it simple, download and run my tool and it will remove these cards for the user. After the removal the user will need to reboot but then they can connect.

Now this doesn’t keep the computer from adding more cards in the future, and I don’t want to disable IPv6, for it is slowly rolling out and when the user actually gets it they should be able to use it. So the current release, v 1.2.2, has a few command line arguments, and will run in graphical mode if no arguments are presented. It is very simple, a few buttons that do their jobs. In the future I want to add a scheduler option, that will allow you to run it monthly automatically so if this problem persists it isn’t a pest, along with a updating function so no need to download a new version if installed.

The download link is below, it requires .Net 2.0, which is already installed on Windows Vista and Windows 7.

https://docs.google.com/leaf?id=0BxiWBWPPWSoLZGEzNGQ3ZTEtMWFlNS00YTBhLTk0NDgtYjY3MDE3NDAxMGU0&sort=name&layout=list&num=50