Tuesday, April 7, 2015

Using BgInfo to Display System Information on the Desktop

If you have ever done system administration, you probably have the problem where you connect to so many servers that you have no idea which computer you are connected to half the time. BGInfo is a great utility that lets you display useful system information right on the desktop. And it works for regular Windows users as well.

    If you’ve been following along with our series, you might be surprised at the huge departure from hunting malware and deleting crapware to displaying stuff on the desktop, but the SysInternals tools aren’t just about finding things to kill. There are also many utilities in the toolkit used for displaying information, and we’re going to look at some of them.
    The BGInfo utility displays information on the desktop, and it works in a server environment as well — in fact, that’s probably where it is the most useful, but it also works on anybody’s computer, so you can test things out on your local machine before running the configuration on the server.
    You can also save information from BGInfo to a text file or even a database without even displaying on the desktop, so if you are looking for a quick way to capture information on all the computers in your network, you can use BGInfo and some batch scripts to solve your problem.
    It’s worth noting that BGInfo displays information by writing text over top of your wallpaper, if you have wallpaper set. It will create a new wallpaper file and then assign that as your new default wallpaper.
    If this isn’t your cup of tea, make sure to read through the rest of the series and wait for tomorrow’s lesson, when we’ll be discussing the very powerful set of PsTools provided by SysInternals.

    Using the BGInfo Interface

    Using BGInfo is very simple: open it and click the Apply button, and your desktop will have a ton of system information plastered all over it right away. If you want that information to update regularly, we’ll need to add a shortcut to the startup folder, or create a scheduled task to do it.

    Looking at the interface up close, you can see that there is an editor, a list of fields, and a bunch of formatting options. You can tweak and change it in any way that you’d like, and even insert data from text files and other places like the registry.

    Once you’ve tweaked and created your configuration (more on that below), you can just save it out to a configuration file to load again any time you need it. Next you’ll need to make sure that BGInfo updates the information on a somewhat regular basis.

    Running BGInfo at Startup

    The simplest thing to do is create a shortcut to BGInfo and place it into your startup folder, and modify that shortcut to include the path to the configuration that you’ve created and saved using the editor. You’ll also need to add a couple of command-line switches to make it happen.

    The important switches for our purposes are the /TIMER:0 switch, which sets the timeout before it applies to zero, the /SILENT switch which keeps everything quiet, and the /NOLICPROMPT switch, which skips the EULA dialog.
    Note: the /POPUP switch and the /TASKBAR switch will stick BGInfo into your system tray and pop up a dialog with system information whenever you click on it, which is definitely a very useful option.
    For example, if we save BGInfo.exe into the C:\Users\Lowell\bin\ folder and put the configuration as config.bgi into the same folder, we’d use this as the command line:
    bginfo.exe c:\users\lowell\bin\config.bgi /timer:0 /nolicprompt /silent
    To make it run every time we startup the computer, open up Windows Explorer and type shell:startup into the location bar to open up the Startup folder.

    Then type out the full path to BGInfo followed by the path to the configuration file, followed by the three switches we mentioned earlier.

    At this point you should have a shortcut in your Startup folder that should immediately display the configuration on the desktop.

    You could also open up Task Scheduler and create a new task that runs every x minutes if you want the information updated more often, but that’s a little beyond the scope of this lesson.

    Tweaking the Displayed Information

    Changing the data that is displayed on the screen is easy enough, as the editor panel is just like any other rich text editor. You can add fields from the pane on the right, tweak the display of the data, etc. For instance, I wanted to just have a line across the top right-hand side of my monitor with some useful system information, and then show the name of the system below it in larger text, so I simply edited, used the align right button, and changed the font size for the element I wanted to change.

    After clicking Apply, this is what displayed in the top right-hand corner of my monitor — handy stuff for a system administrator.

    The Background dialog lets you change the wallpaper behind the image if necessary. For best results, you’d want to use the “Copy user’s wallpaper settings” the first time, and then change to the “Use these settings” to specifically select one if necessary.
    Note: One little problem is that if you create a new configuration, BGInfo gets a little confused and resets your wallpaper to black, so you have to set the wallpaper again, and then apply the configuration.

    You can use the Position button to change where on the screen the data will show up, and tweak a few other variables if necessary.

    Clicking the Custom button underneath the Fields box will let you create user-defined fields that display special data that isn’t normally available, including pulling data from the registry, environment variables, WMI, files, or even VB Script. By extending BGInfo this way, you can make it display absolutely anything that you’d like to see on the desktop.
    For example, if you want to grab the build number of Windows to use as a data point on the desktop, you would click the Registry value and then paste in the full path to a registry key in the Path field. (If you are running 64-bit Windows you would want to check the 64-bit registry view box or your lookup will be redirected to the 32-bit compatibility section of the registry.)
    The Identifier would then show up in the Fields list, and you can select it to insert into the rich text editor.

    For WMI you can actually browse through all of the zillions of pieces of data and pick one to display. This would work the same way as the registry value — you’d give it a name, and then add that name to the rich text editor from the fields list.

    For the text file and VB Script user defined fields, you can pull in either the contents of a text file, which can come from anywhere, or you can create a VB script that runs on the command line and outputs data that illustrates anything you’d like.
    For instance, to show your public IP address on the desktop, you could create a new script in Notepad, paste the following, and then save it as publicip.vbs.
    Dim o
    Set o = CreateObject("MSXML2.XMLHTTP")
    o.open "GET", "http://ifconfig.me/ip", False
    o.send
    echo o.responseText
    Once you added this to the list, you would then have access to display the public IP address by adding “publicip” out of the Fields list. As you can imagine, there is a lot more that you can do with this, to the point of being nearly unlimited.

    No comments:

    Post a Comment