The Desktop Information Stamp
Novell Cool Solutions: Feature
By Jim Shank
Digg This -
Posted: 25 Apr 2003
How many times have you had to login to a computer just to find out its IP address? How about the system serial number? Maybe you just want to know if the virus definitions are up-to-date? Even more difficult, have you had to walk an employee through finding his or her own IP address? With a little bit of VBScripting and a great free utility from Sysinternals called bginfo, you can provide all of this data on the desktop and login screen. Combine it with a slick looking corporate background and you will have a sharp looking usable desktop and login screen.
The Desktop Information Stamp can provide a vast amount of information. In our environment, it provides the machine name, OS, Service Pack, IP address, Domain, NAV Definition file version and system serial number. Right below all of that is the help desk number so the employees never lose it.
BGInfo provides quite a few fields that you can automatically include without using any scripting. It also includes the ability to add information from a text file, the Windows registry, an environment variable or even the version information from a file.
(Cautionary Note from reader: BGInfo is a "free" utility, but its licensing specifically mentions it's only free when downloaded directly from SysInternals onto the machine it will be running on. Distribution in any other way (NAL, login script, e-mail, whatever) requires a commercial license.)
Even with all of this information, there are still a few things you may want to extract such as the system serial number from WMI. The other opportunity you have is to format text using VBScript since sometimes it isn't stored in the registry in the most user-friendly manner. Here is where our script comes into place. Let's take a look at how it all works. Once again, it's time to print out the VBScript (found in corpdt.zip below), grab a drink and follow along with the description below.
- I always begin by using Option Explicit so that I can declare my variables. If I typo a variable name later (I know, it never happens to you), the error message will tell me instead of the output going missing. Notice the On Error Resume Next -- this is the VBScript way of saying, "If something goes south, don't tell the end user." Make sure to put this in only when you have run through beta testing for a while.
- We are going to be creating our own little key in the registry to store the variables for quick retrieval later. The first thing we do is create the default key.
- Now we get to dig into the WMI or Windows Management Interface. This interface contains a vast amount of data from the system BIOS and can provide some great troubleshooting information. For a detailed explanation of what information you can retrieve from WMI, check out http://msdn.microsoft.com/library/en-us/wmisdk/wmi/wmi_classes.asp. (Be careful though, this will make you a borderline programmer if you read too much of it. Pay particular attention to the Win32_BIOS class that I use in the example.)
- First we check to make sure that WMI is installed and exists. The easiest way to do this is check for the existence of the winmgmt.exe file.
- Next we open up the WMI interface and loop through the Win32_BIOS class until we find the PC serial number.
- We then write the PC Serial Number to our registry key so we can access this value from bginfo.
- If we were unable to find the winmgmt.exe file, we popup an error for the employee to contact the helpdesk so we can fix the error. We also put an error message for bginfo to read and display in place of the serial number.
- Next we are going to extract the virus definition file information. We of course want to make sure our anti-virus application is already installed so we check for the presence of C:\Program Files\NavNT\rtvscan.exe.
- For Symantec Norton Antivirus, the registry key
holds the path to the virus definitions file. Luckily for us, this file is named as the date and revision of the virus definitions file.
- We will be using the handy split function in VBScript to slice up the text string into sections separated by the \ character. This will allow us to access just the filename, thus giving us the definition file version.
- By looking at part 5 of the file path array from our split, we find the actual filename and assign that variable. Just count the number of directories (starting from 0) in the file path; the last one should be your file.
- After all that work we write the definition variable to our registry key.
- Of course if we didn't find NAV installed in our earlier test, we write NAV Not Installed to the same key so we know that it is missing.
- The next section is a little coding I wrote to keep the desktop resolution from getting changed by the users, should they figure out a way around the Windows 2000 GPO. You will have to check in HKEY_CURRENT_CONFIG\System\CurrentControlSet\SERVICES\ <your device>\DEVICE0\DefaultSettings.Xresolution to see what the current resolution is set at. I have to check a couple depending on what video driver is installed.
- We first read the x resolution (resolution is x by y or 1024 by 768) and store it in a variable.
- We next read the x resolution from another key in case it's a different video driver.
- The check of Err.number says, "If there is an error reading that key (probably because it doesn't exist) just set it to the x resolution you found in the first key."
- We repeat the process one more time for one other video driver.
- Since there are always exceptions, we put in a little check to see if a file, resfix.txt, exists. If it does, we don't change the resolution back to our standard.
- Otherwise, if we found that the resolution wasn't what we want it set to, we change it back using the handy Video Resolution Changer 1.0 by Tony Pombo.
- Finally, we run bginfo to use the settings file we exported previously and run it immediately.
Bginfo.exe has a host of switches, all well documented in the help. What you will need is a background, preconfigured with an area that the stamp will show up on and be readable.
I have tried to give credit to the sources of the code and utilities used within this program. If there is anyone I have missed, please contact me directly and I will gladly add credit or remove the reference to your utility/code upon request. All information contained in this document is expressed by Jim Shank and does not implicitly or explicitly represent official positions and policies of Aurora Loan Services.
This information is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
If you have any questions you may contact Jim at firstname.lastname@example.org
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com