Search

 
Archive
Links
Categories
Admin Login
Sign In

 

 

 

 

Friday, May 29, 2009

Here's a decent article on how to create and add Gadgets to Vista or Windows 7:

 

Creating Your First Gadget

One of the criticisms leveled at Microsoft (and yes, believe it or not some people have criticized Microsoft in the past) is that many of our products were apparently designed to be used by robots or by aliens from the planet Omicron IV; at any rate, they were not designed to be used by human beings. Happily that’s not the case for Microsoft gadgets. (Although if you happen to be either a robot or an alien from the planet Omicron IV rest assured that you can easily create gadgets as well.) To create a gadget you need only two items:

A “manifest” file named Gadget.xml. This manifest contains all the settings for your gadget, including the gadget name, author and copyright information, and information about the HTML page that makes up the actual gadget.

An HTML file (for example, Test.htm). Although they might not look like it, gadgets are really nothing more than HTML files: you simply create an HTML file, add the appropriate tags and script code, and you’ve got yourself a gadget.

Note. Yes, we know: you have no idea what we mean by “the appropriate tags and script code.” Relax; that’s what the rest of this article is for.

Those are the only items required to create a gadget. Granted, as you create more sophisticated gadgets you will find yourself dealing with icon files, graphics files, settings files, and other elements. But we’ll cross those bridges as we come to them.

See how easy that is? What do you mean, “Sure, so far”? Point well taken: this would seem to be the time when you have to do some sort of horrendously-complicated compilation process, probably using some proprietary compiler that the Scripting Guys will sell you for just $39.95 plus shipping and handling. (Actually, now that you mention that we wish we would have thought of doing something like that.) But instead of using some proprietary compiler here’s how you gather up all your files and then “compile” them into a gadget:

1.

Place all the files in a gadgets folder.

That’s it: put all the files in a folder and you’ve got yourself a gadget. No compiling, no compilers, nothing more tedious or technical than simply copying files to a specified folder.

Incidentally, if you still want to send us $39.95 we’ll be happy to take it.

The Gadgets Folder

Of course, there is a slight catch here: you can’t just put your files in any old folder. Instead, you have to follow this procedure:

To begin with, bring up the Gadgets folder. A quick way to access your Gadgets folder is to type the following in the Run dialog box:

%userprofile%\appdata\local\microsoft\windows sidebar\gadgets

Note. What do you mean you can’t find the Run command on the Start menu? Oh, that’s right: for some reason this command is hidden by default. But that’s OK; to get the Run command back just right-click the Start button and then click Properties. In the Taskbar and Start Menu Properties dialog box, on the Start Menu tab, click Customize.

Still with us? Good. Once you’re in the Customize Start Menu dialog box scroll down and check the Run command check box. Click OK a couple times and the Run command will be back to its rightful place.

And, yes, usually the Scripting Guys do charge $39.95 for this kind of inside information. But we’ll let you have this one for free.

Inside the Gadgets folder create a new folder. Give this folder any name you want, provided that the name ends with a .gadget file extension (for example, Test.gadget). Obviously it will make your life easier if the name of the folder bears some resemblance to the gadget contained within. However, the operating system merely uses this folder to identify that the files inside make up a gadget; the gadget name is derived from information found in the manifest, not from the folder name (as the Scripting Guys discovered the hard way).

All you have to do now is place all your files (such as Gadget.xml and Test.htm) in the folder. Does that mean you now have a Microsoft Gadget? You bet it does. In fact, with Windows Sidebar up and running click the + button to bring up the set of gadgets found on your computer. Your gadget will show in the gadget picker dialog box.

Note. What’s that? You can’t find the Windows Sidebar, either? That’s OK; if you can’t find the Windows Sidebar just do this: click the Start menu and then click All Programs. Click Accessories, and you should see a link to the Sidebar.

Installing a Gadget

Assuming your gadget really does show up in the list of available gadgets, you can install the thing simply by dragging the icon onto the Windows Sidebar and then releasing the mouse button. (Or just right-click the gadget icon and then click Add.) The gadget will be displayed, and you’ll be ready to start using it. If you decide to remove the gadget from the Sidebar just hold the mouse over the thing and click the little X that appears in the upper right-hand corner. If you aren’t sure which little X we’re talking about, well, it’s this one:

Microsoft Gadgets

The Manifest File

As we noted earlier, to create a gadget you need only two things: a manifest file and an HTML file. And we know what you’re thinking: sure, on Omicron IV you guys probably use manifest files all the time. (Some of us do, some of us don’t.) But what do system administrators know about manifest files?

Well, one thing you know (or at least now you know) is that “manifest file” is simply a high-falutin’ technical term; in essence we’re really just talking about something like an .INI file, a simple text file (in this case, one done in XML) that contains configuration information for the gadget. Admittedly, the idea of having to write things in XML might send a shiver or two up and down your spine. Listen, don’t worry about it; this is about as simple and barebones an XML file as you’ll ever have to deal with.

Here’s what we mean:

<?xml version="1.0" encoding="utf-8" ?>

<gadget>
    <name>My First Gadget</name>
    <author>The Microsoft Scripting Guys</author>
    <copyright>2006 Microsoft Corporation</copyright>
    <description>Sample gadget that returns the name of the installed operating system.</description>
    <icons>
        <icon>icon.png</icon>
    </icons>
    <version value="1.0.0.0" MinPlatformVersion="0.1"></version>
    <sidebar>
        <type>html</type>
        <permissions>full</permissions>
        <code>test.htm</code>
        <website>www.microsoft.com/technet/scriptcenter</website>
     </sidebar>
</gadget>

Before you ask, yes, you can simply copy this file and use it pretty much as-is, just making changes (as needed) to a few of the tag values. (And don’t forget, you must name the file Gadget.xml.) The tags you might want to/need to modify are specified in the following table:

Tag

Description

<name>

Name of the gadget as it appears in the gadget picker dialog box.

<author>

Name of the person who wrote the gadget. The author, copyright, and description tags all appear in the gadget picker when you click on a particular gadget. For details, see the illustration shown below.

<copyright>

Copyright information, including name of the copyright holder and copyright date.

<description>

Brief description of the gadget and what it does.

<icon>

Name of the icon file (the icon is the graphic displayed in the gadget picker). For more on icons, see Creating an Icon in the following subsection of this document.

<code>

Probably not the most intuitive tag name in the world, but this is the name of the HTML file that makes up your gadget.

<website>

Web site associated with the gadget.

To help make this all a little plainer, here are the manifest file elements mapped to the items displayed in the gadget picker dialog box:

Microsoft Gadgets


Creating an Icon

It’s up to you whether you want to supply a custom icon with your gadget; if you don’t supply an icon (or if you don’t specify an icon in the manifest file) the gadget picker will provide you with a default icon. (At no charge to you.)

If you do decide to supply a custom icon, keep in mind that “icon” is just a name given to a regular old image file; these are not true Windows icons, graphics that must be created using special software. Instead an icon is just a picture file, be it a .GIF, .JPG, or .PNG graphic. The sample gadgets that ship with Windows Vista all use .PNG graphics; that’s probably because .PNG graphics allow for transparent backgrounds, giving you the ability to make very cool-looking pictures. (Assuming you have the requisite artistic talent.) However, you don’t have to save your icons as .PNG files. Instead, load up Paint, create an icon, and save it as a .JPG file; your icon will show up just fine in the gadget picker.

Good question: what size should you make your icon? The optimal size is 64 pixels by 64 pixels. The gadget picker will resize your image to fit, but creating a 64x64 icon in the first place will help guard against any image distortion created if the gadget picker needs to shrink or stretch the image to fit the allotted space.

In case you’re wondering, here’s the icon we used for this article:

Microsoft Gadgets


We liked it, too.

Note. You might have noticed that, the in the manifest file, the <ICON> tag is embedded within an <ICONS> tag:

<icons>
    <icon>icon.png</icon>
</icons>

Does that mean you can add additional icons to the manifest file? Probably, although, to be honest, we aren’t sure what you would use those additional icons for. That’s something we’ll look into.

The HTML File

The HTML file that makes up the gadget itself is actually no different than any Web page that uses dynamic HTML; in fact, to create the HTML file you simply use any valid HTML tagging (including CSS styles) plus script code. We’ll show you a sample HTML page in just a moment. Before we do that, however, we need to take a brief side trip and talk about how you incorporate WMI code into a gadget.

Working with WMI

As a system administrator you’re used to writing scripts that make heavy use of WMI. That’s understandable; after all, WMI is the technology that helps you manage everything from printers to disk drives to mice and monitors. Best of all, WMI is easy to use. For example, suppose you’d like to know the name of the operating system installed on the local computer. No problem; here’s a WMI script that will return that information for you:

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")

For Each objItem in colItems
    Msgbox objItem.Caption
Next

If you plan on creating gadgets for system administration we’ve got some bad news for you: the WMI scripts you’re used to writing won’t work in a gadget. (Wait, don’t do anything drastic: the news will get better in just a moment, promise.) That’s because, at heart, a gadget is nothing more than a Web page, and, for security reasons, Web pages aren’t able to make use of GetObject. If you place the preceding code in a gadget all you’ll end up with is this error message:

ActiveX component can’t create object: 'GetObject'

Uh-oh.

But don’t panic. You can still use WMI scripts within a gadget; you just can’t use GetObject and the winmgmts: moniker. Instead, you need to use CreateObject to create an instance of the WbemScripting.SWbemLocator object, then use the ConnectServer method to connect to the WMI service. In other words, you need to write a script that looks like this:

strComputer = "."

Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")

For Each objItem in colItems
    Msgbox objItem.Caption
Next

See? Like we said, no need to panic. (Although, in all fairness, it was probably our fault that you panicked in the first place.) The only difference between a script that uses the WMI moniker and a script that uses ConnectServer comes when you make a connection to the WMI service. You’re used to making that connection using a single line of code:

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Now you have to use two lines of code to make the connection (yes, doubling your workload!): you create an instance of the WbemScripting.SWbemLocator object, then you use the ConnectServer method to bind to the WMI service. Notice that we pass ConnectServer two parameters, the name of the computer to connect to (represented by the variable strComputer) and the WMI namespace we want to connect to (in this case, root\cimv2):

Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2")

Got all that? Good. Now let’s return to our regularly-scheduled article.

Creating an HTML File

As we’ve already noted, a gadget is just an HTML file. That means that any elements (including dynamic elements) you can use in an HTML page can also be used in a gadget. As you’ve probably already figured out, this includes VBScript code; although most of the early gadgets made available through the Microsoft Gadgets Web site use JScript or JavaScript, VBScript works just fine (as you’ll soon see).

We’ve already shown you a WMI script that returns the name of the operating system installed on the local computer; with that in mind, let’s see if we can turn that script into a gadget. We’ll start off very simple, creating a gadget that consists of a single button that, when clicked, displays the value of the operating system Caption property in a message box. Here’s the HTML code for our gadget:

<html>

<head>
    <title>My First Gadget</title>

    <style>
        body{width:120;height:160}
    </style>

</head>

<script language="VBScript">

    Sub RunSub
        strComputer = "."

        Set objLocator = CreateObject("WbemScripting.SwbemLocator")
        Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2")

        Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")

        For Each objItem in colItems
            Msgbox objItem.Caption
        Next
    End Sub

</script>

<body>
    <input type="button" value="Run" name="run_button" onClick="RunSub">
</body>

</html>

As you can see, there’s nothing “gadgety” about the code; this is rudimentary HTML that doesn’t do much more than display a single button on a page. When that button is clicked, a subroutine named RunSub is executed; that subroutine then uses WMI to determine the name of the operating system installed on the computer.

Note. OK, maybe this is rudimentary HTML for some people, but what if you have no background with HTML coding? If that’s the case, then you might want to take a look at our two-part HTA Tutorial. That will help bring you up to speed on things such as <SCRIPT> tags and <INPUT> tags.

About the only thing we need to make special note of here is the <STYLE> tag. As we start creating more sophisticated gadgets we’ll discuss the <STYLE> tag in detail; for now, however, we’ll simply point out that we use this tag to configure the default height and width of our gadget:

<style>
    body{width:120;height:160}
</style>

This tag simply says that we want our gadget to be 120 pixels wide (the Windows Sidebar is approximately 130 pixels wide) by 160 pixels tall. For this particular gadget 160 pixels might be too tall; if that’s the case, then we can simply assign a different value to the height property:

<style>
    body{width:120;height:40}
</style>

When you install this gadget it will look like this in the Windows Sidebar:

Microsoft Gadgets


And here’s what happens when you click the button:

Microsoft Gadgets


Go ahead and write home to Mom, telling her all about the cool gadget you just created. Just let us know when you’re done and then we’ll move on to something else.

Displaying Data in a <SPAN>

So far we’ve created a gadget that, when we click a button, displays the name of the operating system in a message box. There’s nothing wrong with that, and there will likely be times when your gadget returns so much information that you have no choice but to display that information in a message box, an Internet Explorer window, or some other location.

On the other hand, sooner or later you will also create gadgets where it makes no sense to display information in a message box, and where it makes no sense to have to click a button in order to return that information. For example, suppose you decided to create a clock for your Windows Sidebar. That’s great, but do you really want to be forced to click a button each time you want to find out what time it is? And when you do, do you want that time to pop up in a message box? Sure, on Omicron IV we like that sort of thing. But human beings find that a bit tedious, not to mention downright silly.

In other words, we need the ability to create gadgets that can:

Display data within the bounds of the gadget itself. Later in this series we’ll show you ways to display this information graphically, but for now we’ll focus on text-based displays.

Retrieve data automatically, without requiring user interaction of any kind.

Periodically update that information. For example, a gadget that monitors available memory on a computer (a gadget we’ll create shortly) can’t just retrieve available memory at the time it loads and then call it good. Instead, it needs to periodically take a new, up-to-date memory sample.

That sounds like a lot, but we’ll make it easy by learning these skills one-at-a-time. Let’s start by discussing the <SPAN> tag, a simple and easy way to display information within the body of the gadget itself.

Here’s a revised version of our HTML file. In this new gadget you still click a button in order to call the subroutine RunSub; however, this time around the operating system name is not echoed back in a message box but is, instead, written to the gadget itself:

<html>

<head>
    <title>My First Gadget</title>
    <style>
        body{width:120;height:160}
    </style>
</head>

<script language="VBScript">

    Sub RunSub
        strComputer = "."

        Set objLocator = CreateObject("WbemScripting.SwbemLocator")
        Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2")

        Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")

        For Each objItem in colItems
            DataArea.InnerHTML = objItem.Caption
        Next
    End Sub

</script>

<body>
    <input type="button" value="Run" name="run_button" onClick="RunSub"><br>
    <span id="DataArea"></span>
</body>

</html>

When we click the button on this gadget the returned information is displayed within the gadget itself:

Microsoft Gadgets


Cool.

An Extra Bonus: Spiffing Up a Gadget’s Background

We’ll talk more about creating fancy-looking gadgets in future installments of this series. For now, we thought we’d mention a few simple little techniques you can use to spiff up your gadgets. For example, suppose you have a graphic that you think will make a good background for a gadget. In that case, all you have to do is set the background attribute of the <BODY> tag of your HTML file. This line of code causes your gadget to use a file named Background.jpg as the gadget background:

<body background = "background.jpg">

Just make sure that Background.jpg is stored in your gadget folder.

Alternatively, you can create a gadget with a different background color by adding the bgcolor parameter to the <BODY> tag. Dying to have a gadget with a bright red background? Hey, why not?

<body bgcolor = "red">

Finally, you can give your gadget a gradient background by using one of the Microsoft multimedia Web filters. In this gadget, we’ve modified the <BODY> style in two ways:

We’ve set the font to be white, 8-point Arial.

We’ve added a gradient filter.

Here’s what the code for our modified gadget looks like:

<html>

<head>
    <title>My Gadget</title>
    <style>
        body{width:120;height:160;font:8 pt Arial;color:white;
        filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr="#000000",
            EndColorStr="#0000FF")}
    </style>
</head>

<script language="VBScript">

    Sub RunSub
        strComputer = "."
        Set objLocator = CreateObject("WbemScripting.SwbemLocator")
        Set objWMIService = objLocator.ConnectServer(".", "root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")
        For Each objItem in colItems
            DataArea.InnerHTML = objItem.Caption
        Next
    End Sub

</script>

<body>
    <input type="button" value="Run" name="run_button" onClick="RunSub"><P>
    <span id="DataArea"></span>
</body>

</html>

And here’s what the gadget itself looks like:

Microsoft Gadgets


It’s not a work of art, but it’s better than just having a plain white box plopped down in the Sidebar.

Note. For more information about using the gradient filter see the HTA Developer’s Center.

Creating an “Auto-Run” Gadget

Having a gadget display information in the body of the gadget (as opposed to in a message box) is a nice step forward, and more in tune with the spirit of gadgets. However, we still have to click a button in order to get that information. Surely there must be a way to have that information automatically gathered and displayed the moment the gadget is loaded.

You bet there is. And stop calling us Shirley.

Here’s a gadget that automatically retrieves and displays the name of the installed operating system, no button-clicking required:

<html>

<head>
    <title>My First Gadget</title>
    <style>
        body{width:120;height:160}
    </style>
</head>

<script language="VBScript">

    Sub Window_OnLoad
        RunSub
    End Sub

    Sub RunSub
        strComputer = "."

        Set objLocator = CreateObject("WbemScripting.SwbemLocator")
        Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2")

        Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")

        For Each objItem in colItems
            DataArea.InnerHTML = objItem.Caption
        Next
    End Sub

</script>

<body>
    <span id="DataArea"></span>
</body>

</html>

As you can see, this looks very similar to our previous gadget. In fact, there are only two differences:

We removed the button from the gadget. That means there’s no longer any need to click something (for that matter, there’s no longer anything to click).

We added a Window_OnLoad subroutine.

As many of you know, the Window_Onload subroutine – when included in a Web page – is designed to run any time that Web page is loaded or refreshed. This subroutine functions exactly the same way when included in a gadget: it automatically runs any time the gadget is loaded up. That’s how we create an auto-run gadget: we simply create a subroutine named Window_OnLoad and put the code we want run at load time into that subroutine.

For this particular gadget our Window_OnLoad subroutine looks like this:

Sub Window_OnLoad
    RunSub
End Sub

As you can see, all we do in this particular subroutine is call a second subroutine: RunSub. We should point out that we don’t have to put our WMI code in a separate subroutine; we could have put our WMI script in the Window_OnLoad subroutine and directly executed that code upon startup. So why did we create a superfluous second subroutine? That’s easy: it makes for a nice transition to our next gadget.

In case you’re wondering, here’s what our “button-less” gadget looks like:

Microsoft Gadgets

Creating an “Auto-Refresh” Gadget

Undoubtedly gadgets will earn their keep in large part by serving as monitoring devices, dutifully keeping tabs on anything and everything from free disk space to network connectivity to available memory. Gadgets are perfect for tasks like this: they are small and unobtrusive, yet gadgets can still display visual cues that provide information at a glance. Equally important, gadgets can be programmed to take action when specific conditions arise. By combining small size and graphical capabilities with custom script code you can create incredibly useful tools for monitoring the health and well-being of your network.

Of course, the ability to do that hinges on the gadget’s ability to constantly update its information. It’s important that, at startup, a gadget can ping a server and verify that server’s availability. However, as a monitoring tool your gadget is of little use if it can only ping the server at startup. Instead, the gadget needs to periodically refresh itself: at regular intervals it needs to retrieve up-to-date information. In other words, it needs to do something like this:

<html>

<head>
    <title>My Gadget</title>
    <style>
        body{width:120;height:40"}
    </style>
</head>

<script language="VBScript">

    Sub Window_Onload
        GetMemory
        iTimerID = window.SetInterval("GetMemory", 10000)
    End Sub

    Sub GetMemory
        Set objLocator = CreateObject("WbemScripting.SwbemLocator")
        Set objWMIService = objLocator.ConnectServer(".", "root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")
        For Each objItem in colItems
            DataArea.InnerHTML = objItem.FreePhysicalMemory
        Next
    End Sub

</script>

<body>
    <span id="DataArea"></span>
</body>

</html>

Before we discuss how this script works we should note that this particular script doesn’t display the name of the operating system installed on the computer; instead, it displays the amount if available memory on the computer. Why did we suddenly drop the operating system gadget in favor of an available memory gadget? Well, we’re assuming that you don’t need to constantly monitor the name if the installed operating system; its safe to say that the name of the operating system doesn’t change anywhere near as often as available memory does. We figured that monitoring available memory might be a bit more realistic than monitoring the name of the installed operating system.

Incidentally, the subroutine for actually determining the current amount of available memory (a subroutine named GetMemory) looks like this:

Sub GetMemory
    Set objLocator = CreateObject("WbemScripting.SwbemLocator")
    Set objWMIService = objLocator.ConnectServer(".", "root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")
    For Each objItem in colItems
        DataArea.InnerHTML = objItem.FreePhysicalMemory
    Next
End Sub

What we’re interested in here, however, isn’t the GetMemory subroutine but the Window_OnLoad subroutine:

Sub Window_Onload
    GetMemory
    iTimerID = window.SetInterval("GetMemory", 10000)
End Sub

As you can see, we do two things in this subroutine. First, we call the GetMemory subroutine; we do that to ensure that, upon loading our gadget, the available memory is immediately displayed in the gadget. The second thing we do is a bit more interesting:

iTimerID = window.SetInterval("GetMemory", 10000)

With this line of code we’re using the SetInterval method to create a timer. What this timer does is cause our gadget to call the GetMemory subroutine every 10 seconds (10,000 milliseconds). This is how we cause the gadget to auto-refresh itself: every 10 seconds the gadget calls the GetMemory subroutine, which means that every 10 seconds the gadget will use WMI to get the current amount of available memory and then display that data in the gadget body. If 10 seconds is too long between measurements, then change the parameter 10000 to a smaller number; for example, setting the parameter to 5000 will cause the gadget to update itself every 5 seconds (5000 milliseconds). Likewise, change the 10000 to a larger number if you’d prefer to have a longer interval between measurements.

Here’s our new gadget in action:

Microsoft Gadgets


We never said it was a work of art. But now that we understand the basics behind creating gadgets (particularly gadgets of interest to system administrators) we’re about ready to start creating works of art. We’ll talk about incorporating graphics into gadgets soon; in addition, we’ll also explore the Gadget object model and some of the really cool things you can do with that.

A Preview of Coming Attractions

In order to give you more of a taste for what gadgets can do, here’s a slightly (with the emphasis on the word slightly) more complicated gadget, one that does two things: it monitors available memory and also displays (in a Web page) more detailed system information when the Information button is clicked. Needless to say, this doesn’t even begin to scratch the surface of what gadgets can do, but it does give you a better sense for the range of capabilities that can be included in a single gadget.

You’re on your own to figure out the whys and wherefores of this particular gadget (we’ve already run out of space for this month) but here’s the code:

<html>

<head>
    <title>My Gadget</title>
    <style>
        body{width:120;height:80}
    </style>
</head>

<script language="VBScript">

    Sub Window_Onload
        GetMemory
        iTimerID = window.SetInterval("GetMemory", 10000)
    End Sub

    Sub GetMemory
        Set objLocator = CreateObject("WbemScripting.SwbemLocator")
        Set objWMIService = objLocator.ConnectServer(".", "root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")
        For Each objItem in colItems
            DataArea.InnerHTML = objItem.FreePhysicalMemory
        Next
    End Sub

    Sub RunSub

        Set objLocator = CreateObject("WbemScripting.SwbemLocator")
        Set objWMIService = objLocator.ConnectServer(".", "root\cimv2")

        Set colItems = objWMIService.ExecQuery("Select * From Win32_ComputerSystem")
        For Each objItem in colItems
            strHTML = "Computer Name: " & objItem.Name & "<br>"
            strHTML = strHTML & "User Name: " & objItem.UserName & "<br><br>"
        Next

        Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")
        For Each objItem in colItems
            strHTML = strHTML & "Operating System: " & objItem.Caption & "<br>"
            strHTML = strHTML & "Service Pack: " & objItem.ServicePackMajorVersion & "<br><br>"
        Next

        Set colItems = objWMIService.ExecQuery("Select * From Win32_Processor")
        For Each objItem in colItems
            strHTML = strHTML & "Processor: " & objItem.Caption & "<br><br>"
        Next

        Set colItems = objWMIService.ExecQuery _
            ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
        For Each objItem in colItems
            strHTML = strHTML & objItem.Caption & "<br>"
            For Each strAddress in objItem.IPAddress
                strHTML = strHTML & "IP Address: " & strAddress & "<br>"
            Next
        Next

        Set objIE = CreateObject("InternetExplorer.Application")
        objIE.Navigate("about:blank")
        objIE.Toolbar = 0
        objIE.StatusBar = 0
        Set objDoc = objIE.Document.Body
        objDoc.InnerHTML = strHTML
        objIE.Visible = True
    End Sub

</script>

<body>
    <span id="DataArea"></span><p>
    <input type="button" value="Information" name="run_button" onClick="RunSub">
</body>

</html>
From: (http://www.microsoft.com/technet/scriptcenter/topics/vista/gadgets-pt1.mspx)
Friday, May 29, 2009 12:42:36 AM (Central Standard Time, UTC-06:00) | Comments [2] | KnowledgeBaseArticles | Windows 7#

I use i-Catcher to monitor cameras.  When I use the i-Catcher console from Windows 7 64bit build 7100 in Internet Explorer 8, it forces Aero to shut down.  i-Catcher uses Java to render the camera views so I assume that the java control for the video is the problem but have yet to find a work-around.  Anyone else having this problem and/or found a solution?

Thursday, May 28, 2009 11:51:16 PM (Central Standard Time, UTC-06:00) | Comments [1] | Internet Explorer 8 | Windows 7#
Friday, May 22, 2009

As I find myself testing Windows 7 and going through articles of "new stuff" to test out and like or not, I keep coming back to a common theme: The worst part I've found so far in Windows 7 is Internet Explorer 8.  Win 7 itself seems to run smoothly and, albeit with the right hardware, fast.  I have been running 64-bit Windows 7 for over 2 weeks now and have been skeptically happy.  The only major problems I keep running into are glitches in Internet Explorer 8.  What gives?  The latest Firefox build does not seem to have the same issues.

Friday, May 22, 2009 1:16:04 AM (Central Standard Time, UTC-06:00) | Comments [2] | Internet Explorer 8 | Windows 7#

Is it just me or are there some bugs in IE8?  I am getting weird scroll patterns in Facebook - none of which can I recreate in Firefox.  It seems like there is a problem with the scrolling keeping up with the screen draws.  Anyone else notice this pattern?

Friday, May 22, 2009 1:06:59 AM (Central Standard Time, UTC-06:00) | Comments [2] | Internet Explorer 8#
Wednesday, May 20, 2009
  1. Windows Management. By now, you’ve probably seen that Windows 7 does a lot to make window management easier: you can “dock” a window to the left or right half of the screen by simply dragging it to the edge; similarly, you can drag the window to the top of the screen to maximize it, and double-click the window top / bottom border to maximize it vertically with the same horizontal width. What you might not know is that all these actions are also available with keyboard shortcuts:
    • Win+Left Arrow and Win+Right Arrow dock;
    • Win+Up Arrow and Win+Down Arrow maximizes and restores / minimizes;
    • Win+Shift+Up Arrow and Win+Shift+Down Arrow maximizes and restores the vertical size.

    This side-by-side docking feature is particularly invaluable on widescreen monitors – it makes the old Windows way of shift-clicking on two items in the taskbar and then using the context menu to arrange them feel really painful.

  2. Display Projection. Had enough of messing around with weird and wonderful OEM display driver utilities to get your notebook display onto an external projector? In that case, you’ll be pleased to know that projection is really quick and simple with Windows 7. Just hit Win+P, and you’ll be rewarded by the following pop-up window:
    The Win+P Projector Settings window allows you to quickly switch display settings. 
    Use the arrow keys (or keep hitting Win+P) to switch to “clone”, “extend” or “external only” display settings. You can also access the application as displayswitch.exe.

    If you want broader control over presentation settings, you can also press Win+X to open the Windows Mobility Center, which allows you to turn on a presentation “mode” that switches IM clients to do not disturb, disables screensavers, sets a neutral wallpaper etc. (Note that this feature is also available in Windows Vista.)
  3. Cut Out The Clutter. Working on a document in a window and want to get rid of all the extraneous background noise? Simply hit Win+Home to minimize all the non-active background windows, keeping the window you’re using in its current position. When you’re ready, simply press Win+Home again to restore the background windows to their original locations.
  4. Multi-Monitor Windows Management. The earlier tip on window management showed how you can dock windows within a monitor. One refinement of those shortcuts is that you can use Win+Shift+Left Arrow and Win+Shift+Right Arrow to move windows from one monitor to another – keeping them in the same relative location to the monitor’s top-left origin.
  5. Command Junkies Only. One of the most popular power toys in Windows XP was “Open Command Prompt Here”, which enabled you to use the graphical shell to browse around the file system and then use the context menu to open a command prompt at the current working directory. In Windows 7 (and in Windows Vista, incidentally – although not many folk knew about it), you can simply hold the Shift key down while selecting the context menu to get exactly the same effect. If the current working directory is a network location, it will automatically map a drive letter for you.
  6. It’s a Global Village. If you’ve tried to change your desktop wallpaper, you’ve probably noticed that there’s a set of wallpapers there that match the locale you selected when you installed Windows. (If you picked US, you’ll see beautiful views of Crater Lake in Oregon, the Arches National Park, a beach in Hawai’i, etc.) In fact, there are several sets of themed wallpapers installed based on the language you choose, but the others are in a hidden directory. If you’re feeling in an international mood, simply browse to C:\Windows\Globalization\MCT and you’ll see a series of pictures under the Wallpaper directory for each country. Just double-click on the theme file in the Theme directory to display a rotation through all the pictures for that country. (Note that some countries contain a generic set of placeholder art for now.)
  7. The Black Box Recorder. Every developer wishes there was a way that an end-users could quickly and simply record a repro for the problem that they’re running into that is unique to their machine. Windows 7 comes to the rescue! Part of the in-built diagnostic tools that we use internally to send feedback on the product, the Problem Steps Recorder provides a simple screen capture tool that enables you to record a series of actions. Once you hit “record”, it tracks your mouse and keyboard and captures screenshots with any comments you choose to associate alongside them. Once you stop recording, it saves the whole thing to a ZIP file, containing an HTML-based “slide show” of the steps. It’s a really neat little tool and I can’t wait for it to become ubiquitous on every desktop! The program is called psr.exe; you can also search for it from Control Panel under “Record steps to reproduce a problem”.
    The Problem Steps Recorder provides an easy way for users to record a problem repro for later diagnosis.
  8. The Font of All Knowledge. Long Zheng will be happy: we’ve got rid of the Add Fonts dialog that has served Windows faithfully for the last twenty years. (Of course, for most of that time, it’s been deprecated – the easy way to install a set of fonts has simply been to drag them into the Fonts folder via Control Panel.) But now font installation is really easy – we’ve added an “Install” button to the font viewer applet that takes care of the installation process:
    You can install a font in Windows 7 from the standard font viewer dialog.
    There are lots of other new features built into Windows 7 that will satisfy those of a typographic bent, incidentally – grouping multiple weights together, the ability to hide fonts based on regional settings, a new text rendering engine built into the DirectWrite API, and support in the Font common file dialog for more than the four “standard” weights. For example:
    The new common font dialog in Windows 7 supports more than four weights for a font. 
  9. Gabriola. As well as the other typographic features mentioned above, Windows 7 includes Gabriola, an elaborate display type from the Tiro Typeworks foundry that takes advantage of OpenType Layout to provide a variety of stylistic sets, flourishes and ornamentation ligatures:
    Some sample variants of the Gabriola display font.
  10. Who Stole My Browser? If you feel like Internet Explorer is taking a long time to load your page, it’s worth taking a look at the add-ons you have installed. One of the more helpful little additions in Internet Explorer 8 is instrumentation for add-on initialization, allowing you to quickly see whether you’re sitting around waiting for plug-ins to load. Just click Tools / Manage Add-ons, and then scroll right in the list view to see the load time. On my machine, I noticed that the Research add-on that Office 2007 installs was a particular culprit, and since I never use it, it was simple to disable it from the same dialog box.
  11. Rearranging the Furniture. Unless you’ve seen it demonstrated, you may not know that the icons in the new taskbar aren’t fixed in-place. You can reorder them to suit your needs, whether they’re pinned shortcuts or running applications. What’s particularly nice is that once they’re reordered, you can start a new instance of any of the first five icons by pressing Win+1, Win+2, Win+3 etc. I love that I can quickly fire up a Notepad2 instance on my machine with a simple Win+5 keystroke, for instance.

    What’s less well-known is that you can similarly drag the system tray icons around to rearrange their order, or move them in and out of the hidden icon list. It’s an easy way to customize your system to show the things you want, where you want them.
  12. Installing from a USB Memory Stick. My wife has a Samsung NC10 netbook (very nice machine, by the way), and we wanted to install Windows 7 Beta on this machine to replace the pre-installed Windows XP environment. Like most netbook-class devices, this machine has no built-in media drive, and nor did I have an external USB DVD drive available to boot off. The solution: I took a spare 4GB USB 2.0 thumbdrive, reformatted it as FAT32, and simply copied the contents of the Windows 7 Beta ISO image to the memory stick using xcopy e:\ f:\ /e /f (where e: was the DVD drive and f: was the removable drive location). Not only was it easy to boot and install from the thumbdrive, it was also blindingly fast: quicker than the corresponding DVD install on my desktop machine.

    It’s also worth noting in passing that Windows 7 is far better suited to a netbook than any previous operating system: it has a much lighter hard drive and memory footprint than Windows Vista, while also being able to optimize for solid state drives (for example, it switches off disk defragmentation since random read access is as fast as sequential read access, and it handles file deletions differently to minimize wear on the solid state drive).
  13. I Want My Quick Launch Toolbar Back! You might have noticed that the old faithful Quick Launch toolbar is not only disabled by default in Windows 7, it’s actually missing from the list of toolbars. As is probably obvious, the concept of having a set of pinned shortcut icons is now integrated directly into the new taskbar. Based on early user interface testing, we think that the vast majority of users out there (i.e. not the kind of folk who read this blog, with the exception of my mother) will be quite happy with the new model, but if you’re after the retro behavior, you’ll be pleased to know that the old shortcuts are all still there. To re-enable it, do the following:
    • Right-click the taskbar, choose Toolbars / New Toolbar
    • In the folder selection dialog, enter the following string and hit OK:
      %userprofile%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch
    • Turn off the “lock the taskbar” setting, and right-click on the divider. Make sure that “Show text” and “Show title” are disabled and the view is set to “small icons”.
    • Use the dividers to rearrange the toolbar ordering to choice, and then lock the taskbar again.

    If it’s not obvious by the semi-tortuous steps above, it’s worth noting that this isn’t something we’re exactly desperate for folks to re-enable, but it’s there if you really need it for some reason. Incidentally, we’d love you to really try the new model first and give us feedback on why you felt the new taskbar didn’t suit your needs.

  14. It’s a Drag. Much play has been made of the Jump Lists feature in Windows 7, allowing applications like Windows Live Messenger to offer an easy task-based entry point. Jump lists replace the default right-click context menu in the new taskbar; another way to access them (particularly useful if you’re running Windows 7 on a one-button MacBook) is by left-clicking and dragging up in a kind of “swooshing” motion. This was designed for touch-enabled devices like the beautiful HP TouchSmart all-in-one PC, where the same gesture applies.

    Another place where you can “swoosh” (not an official Microsoft term) is the IE 8 address bar, where the downward drag gesture brings up an expanded list containing the browser history, favorites and similar entries. The slower you drag, the cooler the animation!
  15. Standards Support. Every review of Windows 7 that I’ve seen has noted the revamped WordPad and Paint applets that add an Office-like ribbon to expose their functionality. Few, however, have noticed one small but hopefully appreciated feature: WordPad can now read and write both the Word 2007-compatible Office Open XML file format but also the OpenDocument specification that IBM and Sun have been advocating:
    WordPad in Windows 7 allows you to save in ODF or OOXML formats. 
  16. Windows Vista-Style Taskbar. I wasn’t initially a fan of the Windows 7 taskbar when it was first introduced in early Windows 7 builds, but as the design was refined in the run up to the beta, I was converted and now actively prefer the new look, particularly when I’ve got lots of windows open simultaneously. For those who really would prefer a look more reminiscent of Windows Vista, the good news is that it’s easy to customize the look of the taskbar to more closely mirror the old version:
    The Windows 7 Taskbar can be configured for a Windows Vista compatibility view. 
    To achieve this look, right-click on the taskbar and choose the properties dialog. Select the “small icons” checkbox and under the “taskbar buttons” setting, choose “combine when taskbar is full”. It’s not pixel-perfect in accuracy, but it’s close from a functionality point of view.
  17. Peeking at the Desktop. While we’re on the taskbar, it’s worth noting a few subtleties. You’ve probably seen the small rectangle in the bottom right hand corner: this is the feature we call “Aero Peek”, which enables you to see any gadgets or icons you’ve got on your desktop. I wanted to note that there’s a keyboard shortcut that does the same thing – just press Win+Space.
  18. Running with Elevated Rights. Want to quickly launch a taskbar-docked application as an administrator? It’s easy – hold down Ctrl+Shift while you click on the icon, and you’ll immediately launch it with full administrative rights (assuming your account has the necessary permissions, of course!)
  19. One More of the Same, Please. I’ve seen a few folk caught out by this one. If you’ve already got an application open on your desktop (for example, a command prompt window), and you want to open a second instance of the same application, you don’t have to go back to the start menu. You can simply hold down the Shift key while clicking on the taskbar icon, and it will open a new instance of the application rather than switching to the existing application. For a keyboard-free shortcut, you can middle-click with the third mouse button to do the same thing. (This trick assumes that your application supports multiple running instances, naturally.)
  20. Specialized Windows Switching. Another feature that power users will love is the ability to do a kind of “Alt+Tab” switching across windows that belong to just one application. For example, if you’ve got five Outlook message windows open along with ten other windows, you can quickly tab through just the Outlook windows by holding down the Ctrl key while you repeatedly click on the single Outlook icon. This will toggle through each of the five Outlook windows in order, and is way faster than opening Alt+Tab and trying to figure out which of the tiny thumbnail images relates to the specific message you’re trying to find.
  21. Walking Through the Taskbar. Another “secret” Windows shortcut: press Win+T to move the focus to the taskbar. Once you’re there, you can use the arrow keys to select a particular window or group and then hit Enter to launch or activate it. As ever, you can cancel out of this mode by hitting the Esc key. I don’t know for sure, but I presume this shortcut was introduced for those with accessibility needs. However, it’s equally valuable to power users – another good reason for all developers to care about ensuring their code is accessible.
  22. image The Widescreen Tip. Almost every display sold these days is widescreen, whether you’re buying a notebook computer or a monitor. While it might be great for watching DVDs, when you’re trying to get work done it can sometimes feel like you’re a little squeezed for vertical space.

    As a result, the first thing I do when I set up any new computer is to dock the taskbar to the left hand side of the screen. I can understand why we don’t set this by default – can you imagine the complaints from enterprise IT departments who have to retrain all their staff – but there’s no reason why you as a power user should have to suffer from default settings introduced when the average screen resolution was 800x600.

    In the past, Windows did an indifferent job of supporting “side dockers” like myself. Sure, you could move the taskbar, but it felt like an afterthought – the gradients would be wrong, the Start menu had a few idiosyncrasies, and you’d feel like something of a second-class citizen. The Windows 7 taskbar feels almost as if it was designed with vertical mode as the default – the icons work well on the side of the screen, shortcuts like the Win+T trick mentioned previously automatically switch from left/right arrows to up/down arrows, and so on. The net effect is that you wind up with a much better proportioned working space.

    Try it – in particular, if you’ve got a netbook computer that has a 1024x600 display, you’ll immediately appreciate the extra space for browsing the Internet. For the first day you’ll feel a little out of sync, but then I guarantee you’ll become an enthusiastic convert!
  23. Pin Your Favorite Folders. If you’re always working in the same four or five folders, you can quickly pin them with the Explorer icon on the taskbar. Hold the right-click button down and drag the folder to the taskbar, and it will be automatically pinned in the Explorer Jump List.
  24. Starting Explorer from “My Computer”. If you spend more time manipulating files outside of the documents folders than inside, you might want to change the default starting directory for Windows Explorer so that it opens at the Computer node:
    The Computer node in Windows 7. 
    To do this, navigate to Windows Explorer in the Start Menu (it’s in the Accessories folder). Then edit the properties and change the target to read:
    %SystemRoot%\explorer.exe /root,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

    If you want the change to affect the icon on the taskbar, you’ll need to unpin and repin it to the taskbar so that the new shortcut takes affect. It’s worth noting that Win+E will continue to display the documents library as the default view: I’ve not found a way to change this from the shell at this time.
  25. ClearType Text Tuning and Display Color Calibration. If you want to tune up your display for image or text display, we have the tools included out of the box. It’s amazing what a difference this makes: by slightly darkening the color of the text and adjusting the gamma back a little, my laptop display looks much crisper than it did before. You’d adjust the brightness and contrast settings on that fancy 42” HDTV you’ve just bought: why wouldn’t you do the same for the computer displays that you stare at every day? 
    image image
    Check out cttune.exe and dccw.exe respectively, or run the applets from Control Panel.
  26. ISO Burning. Easy to miss if you’re not looking for it: you can double-click on any DVD or CD .ISO image and you’ll see a helpful little applet that will enable you to burn the image to a blank disc. No more grappling for shareware utilities of questionable parentage!
    You can burn an ISO image to disk with this built-in utility in Windows 7.
  27. Windows Movie Maker. Windows 7 doesn’t include a movie editing tool – it’s been moved to the Windows Live Essentials package, along with Photo Gallery, Mail and Messenger. Unfortunately, Windows Live Movie Maker is currently still in an early beta that is missing most of the old feature set (we’re reworking the application), and so you might be feeling a little bereft of options. It goes without saying that we intend to have a better solution by the time we ship Windows 7, but in the meantime the best solution for us early adopters is to use Windows Movie Maker 2.6 (which is essentially the same as the most recent update to the Windows XP version). It’s missing the full set of effects and transitions from the Windows Vista version, and doesn’t support HD editing, but it’s pretty functional for the typical usage scenario of home movie editing.
    Windows Movie Maker 2.6 is compatible with Windows 7. 
    Download Windows Movie Maker 2.6 from here:
    http://microsoft.com/downloads/details.aspx?FamilyID=d6ba5972-328e-4df7-8f9d-068fc0f80cfc 
  28. Hiding the Windows Live Messenger Icon. Hopefully your first act after Windows 7 setup completed was to download and install the Windows Live Essentials suite of applications (if not, then you’re missing out on a significant part of the Windows experience). If you’re a heavy user of IM, you may love the way that Windows Live Messenger is front and central on the taskbar, where you can easily change status and quickly send an IM to someone:
    Windows Live Messenger appears by default on the taskbar.
    On the other hand, you may prefer to keep Windows Live Messenger in the system tray where it’s been for previous releases. If so, you can fool the application into the old style of behavior. To do this, close Windows Live Messenger, edit the shortcut properties and set the application to run in Windows Vista compatibility mode. Bingo!
  29. Enjoy The Fish. I’m surprised that not many people seem to have caught the subtle joke with the Siamese fighting fish that is part of the default background, so I’ll do my part at keeping the secret hidden. Check out wikipedia for a clue.
  30. When All Else Fails… There are always those times when you’re in a really bad spot – you can’t boot up properly, and what you really want is something you can quickly use to get at a command prompt so you can properly troubleshoot. Windows 7 now includes the ability to create a system repair disc, which is essentially a CD-bootable version of Windows that just includes the command prompt and a suite of system tools. Just type “system repair disc” in the Start Menu search box, and you’ll be led to the utility.

 

Special Thanks to http://blogs.msdn.com/tims/archive/2009/01/12/the-bumper-list-of-windows-7-secrets.aspx for providing this list.

Wednesday, May 20, 2009 3:27:35 AM (Central Standard Time, UTC-06:00) | Comments [2] | Windows 7#
Tuesday, May 19, 2009

I installed Windows 7 64-bit RC1 two weeks ago today and so far I have been impressed by the performance.  My test workstation is a Dell Inspiron 530.  Processor is an Intel E4500 Core 2 Duo Conroe at 2.20GHz.  Initially I installed the system with 2GB of RAM (PC2-6400) and a 128MB Nvidia GeForce 8300GS.  In this configuration, I achieved a Windows Experience Index of 3.9 with the video card being the lowest index.  I added 2GB of RAM and replaced the video card with a 320MB Nvidia GeForce 8800GTS.  In this configuration, I get a 5.4 experience with the processor and RAM being the bottlenecks (Video is now at 5.9).  Aero is performing well in this configuration.  Installation took 15 minutes from start to finish (8x DVD player and 7200RPM 320GB drive).  One note - Windows Experience Index locked up using the MS drivers for the video cards.  I had to install the driver upgrade from Nvidia for the Experience Index program to run to finish.

So far I have been happy with the new features and performance seems well above Vista.  One of my biggest pet peives in Vista was the networking subsystem.  Now, instead of waiting for a pop-up window to populate when you call on Network Connections (such as VPNs), you click an already present icon in the system tray and the list pops straight up as if it is buffered and not trying to build when called upon. 

I have Office 2007 Ultimate installed with no glitches there yet.  I also have all of my administration tools installed (VPNs, Angry IP Scanner, VNC) and so far all of these apps are running flawlessly. 

The major glitches I have uncovered are in Internet Explorer 8.  Some pages do not load properly (the compatability button can be helpful here at times, but not always).  Screen draws are strange on some sites - I've noticed that text and boxes do not always line up on FaceBook especially when scrolling.  I have Firefox installed and have not yet noticed any problems with it.

I really like the new taskbar.  You can dock icons on the taskbar and when the windows open, the icons stack off the original icon so you always know where it is.  You can also "Pin" program options to the icons.  For instance, I have Remote Desktop docked on the taskbar.  I can then pin all of my most used workstation/server destinations to that icon.  Left-click, and a list of my most used destinations are right there to be picked.

I have started getting used to the sticky notes feature as well.  It can be docked to the taskbar and the notes will always be there until deleted.

So far it seems like UltraVNC server is running well.  Aero automatically disables when remote-controlling the machine with VNC. 

The idea of Libraries was also introduced in Windows 7.  Instead of the usual MY DOCUMENTS, you can have Libraries.  Say I have a bunch of folders on the network that have to do with drivers.  I create a Library called drivers and then add all of the possible locations on the network, locally, or on external drives to that library.  Now, when I need a driver, I search that library instead of all of the individual directories.  One catch is that the server running the network shares must be running Windows Search 4.0 for the search features to work properly.  My server is Windows 2003 with Windows Search 4 installed and seems to work ok (a few glitches here and there).  My guess is that the library feature will work better with Server 2008 shares.

Overall I think the final product is going to be a big improvement over Vista.  I can see companies pushing to this in 2010 as they retire older XP machines that have been doing overtime duty because IT managers did not want to port over to Vista.

Tuesday, May 19, 2009 9:24:03 PM (Central Standard Time, UTC-06:00) | Comments [2] | Windows 7#