Citrix Provisioning Services

Microsoft BGInfo for Windows 7 VMs running in Citrix PVS XenDesktop environments

If you’re running a Citrix VDI implementation using Provisioning Services (PVS) and XenDesktop, you need a way for your help desk and even the end user to easily identify the VM and pertinent system info easily. BGInfo is the tried and true way of doing this in a corporate environment. A simple overlay for the wallpaper. In a PVS environment, a lot of the info you would need to grab from a physical desktop are useless since it all goes away after the VM reboots and you’re back to a clean image. A lot of companies use BGInfo to quickly see troubleshooting data without having to use a management tool or agent. With PVS VMs, troubleshooting itself is rarely necessary. You just tell the user to reboot and they’re back to a clean slate. So BGInfo can be leveraged as more of an identification tool for when the user calls in than a troubleshooting tool. Download BGInfo from Microsoft here:

http://technet.microsoft.com/en-us/sysinternals/bb897557.aspx

I did a little custom BGInfo configuration to capture just the important pieces of info for my Windows 7 PVS XenDesktop environment. Of course this might differ for your environment and you might need more fields but this is a good starting point:

Advertisement. Scroll to continue reading.

1. A Title – let’s the user know they are on a Windows 7 VM and not a workstation. Users can get confused when switching back and forth.

2. Host name – for when the help desk asks the user the name of their VM

3. IP addresses – both the streaming NIC and LAN NIC IPs. Not really necessary in a PVS environment obviously, but nice to have it displayed.

Advertisement. Scroll to continue reading.

4. User Name – good to know what account the user is logging in with

5. Boot Time – very important to know in a PVS environment. You know those calls you get saying a person’s desktop looks completely different from everyone else and after you investigate a bit you figure out they’re on an old version of the image because they haven’t rebooted in forever. Yeah, this will help with that.

6. Write Cache free disk space left – another very important piece of info in a PVS environment. Once the write cache gets filled up, the VM is done and users start calling in. Good to know how much the user has left. Also a good way to gauge if your allocated write cache is truly enough for your environment or if you need to think about growing it.

Advertisement. Scroll to continue reading.

So here’s how my desktop looks, very simple and clean:

I like to bake BGInfo into my images. I just create a folder called c:\BGInfo and copy Bginfo.exe in there. I’ll get to the other 2 files in a second.

Run Bginfo.exe and you get all the default stuff, delete it all and start clean adding just the stuff you need. Here’s how mine looks:

Advertisement. Scroll to continue reading.

Don’t forget to set your settings under Position > Multiple Monitor Configuration for people with more than 1 monitor. I like mine to just be on the primary screen:

And under Desktops, you’ll want to change it for pretty much anyone that hits the VM using any method. I set mine to “Update this wallpaper” for all scenarios and prompt if it has an issue setting it (so I can investigate if anyone reports an issue):

Then go to File > Save As and save your configuration file. It will be saved with the .bgi extension.

Advertisement. Scroll to continue reading.

That’s it for the implementation side. For PVS though, you’re going to have a lot of different NICs and you don’t want a bunch of “0.0.0.0” IPs being displayed. I just wanted my streaming IP and LAN IP displayed. So under Fields click Custom:

and then click New. You will need to create a new field called “IP Addresses” and do a WMI query to pull the IPs of only the active NICs. I used the following query:

SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE

Advertisement. Scroll to continue reading.

Which will look like this when you are entering and Evaluating it:

Make sure to name the Identifier when you are saving it:

Then just add the field and hit apply and you should see both IPs appear.

Advertisement. Scroll to continue reading.

Now the last part is the Write Cache free disk space percentage. I could not find a way to do it from just a simple WMI Query. So I wrote this little .vbs script and stuck it in c:\BGInfo. As you can see, my write cache drive is the Z: so you will need to change the code to whatever drive letter you are using:

Then just create a new Field and set the VB Script for it:

Advertisement. Scroll to continue reading.

Add the field to your config and hit Apply and it should show the percentage free on your desktop. Now just create a group policy to run it every 5 min. Or you can schedule a task to run it every 5 minutes in the VM itself. I like to use these switches:

If you want BGInfo to run just once, it is very easy to do via scheduled task, GPO, login script, registry, or even adding it as a shortcut under Startup. Just Google it, tons of ways out there. But if you want it to run every 5 minutes and refresh the info, the only way to do it is via GPO. If you bake in into a local scheduled task in the image like I mentioned above, it will not work in a provisioned environment. It will attempt to run under the Administrator account of the maintenance image. So if you baked it in as “VM0001\Administrator”, a provisioned VM named VM0054 will not have this account. This will cause the scheduled task to fail. It won’t run under the System account either. The System account won’t run interactively. The task will start but stay running indefinitely and you will get an error like this in the BGInfo log:

Advertisement. Scroll to continue reading.

An error occured while attempting to set the new desktop settings.
Please ensure the current user has rights to change desktop settings:
This operation requires an interactive window station.

To get around all this, use group policy. By default group policy will run the scheduled task under “%LogonDomain%\%LogonUser%” which is exactly what you want. Here is how my group policy looks:

Notice I have 2 triggers. The first trigger is to run BGInfo at login and update the wallpaper. But when opening a VDI session from a Win 7 host, it may open in Desktop Viewer but not in full screen. When the user goes full screen, the desktop wallpaper will not resize automatically and instead appear as tiled. So to get around this, I have a second trigger that runs BGInfo again 30 seconds into the session and runs every 5 min from then on. Hopefully within that 30 seconds, the user will have gone full screen and BGInfo will get a chance to run at the resolution the user will use throughout their session. One thing to note, I suggest adding a 3rd trigger that runs BGInfo on workstation unlock like this:

Advertisement. Scroll to continue reading.

This is very useful in VDI when you go from a Desktop to an iPad for example. Upon login, it will immediately update the wallpaper resolution and run indefinitely every 5 minutes. This is a lot of triggers but it covers all your bases. I really wish BGInfo had a “Fit” setting for the wallpaper like Windows 7 has by default. It would avoid this whole resize mess. Right now BGInfo 4.16 only supports Center, Tile, and Stretch for the wallpaper.

Also if you decide to store the Bitmap BGInfo creates in a central place like c:\BGInfo, make sure Users and/or Authenticated Users have Full Control to c:\BGInfo and all child objects and change the location the .bmp is stored to under this folder. Othwerwise the background may not change for users that are not admins on the VMs:

Lastly, you might get an error like below, but the wallpaper does in fact update.

An error occured opening the Default Desktop registry key.
Please ensure the current user has rights to change Logon Desktop settings:
Access is denied.

Advertisement. Scroll to continue reading.

This is because the user is not an admin and does not have rights to change the Logon Desktop settings. Either give permissions to do this or go back into your .bgi and uncheck the “Display an error when user permissions prevent a Logon Desktop from being modified” option that you had set before for troubleshooting purposes under the Desktops settings in BGInfo. Then the popup will stop.

One thing I’ve been trying to do is brand BGInfo with my company logo. But I don’t want a big white box around it like when you use a jpg. I want to use a transparent gif. BGInfo does not support this from all the things I’ve tried so far. For example, here is the Amazon logo as a transparent gif:

Looks great on a white background but I want to use it with the standard Windows 7 wallpaper which has a gradient. It looks pretty awful because BGInfo flattens it somehow when creating the bmp causing there to be a black background around the logo:

Advertisement. Scroll to continue reading.

But if your company chooses to use a standard wallpaper with no gradient, like a solid white background for example, just edit the background of your logo to match the color of the background and save it as a jpg. Add it to BGInfo and it will look perfect. Here is the Amazon logo (jpg with white background) with BGInfo set to white for the background wallpaper:

Hope this helps. Let me know if you have any questions or suggestions for custom fields to add that might be handy in a PVS XenDesktop environment.

Advertisement. Scroll to continue reading.

4 Comments

  1. Daniel Ruiz

    December 28, 2012 at 2:07 PM

    Excellent and great idea to configure this… thanks for sharing.

    Daniel

  2. Jason Samuel

    December 28, 2012 at 10:34 PM

    @Daniel Ruiz
    Glad to help Daniel!

  3. Mike

    October 12, 2016 at 7:18 AM

    This is similar to the way I have it configured. If there were event that logged when a resolution changed that would be great. Then we could have it run when the resolution changed instead of everyone 5 minutes.

  4. Tim

    June 8, 2023 at 8:58 PM

    First of all, thankyou for the great script

    I was running the script on a VM with the VMWare CD loaded, then I ejected it, leaving a drive in the for loop with no space, causing a run-time type error on that drive where the CD used to be (because intTotalSpace (from objDisk.Size) is now null (or empty?), since the CD was no longer mounted.

    Actual text from the error dialog looks like this
    “Error evaluating scripted field ‘Available disk’
    Microsoft VBScript runtime error
    Line 16, position 8
    Type mismatch: ‘FormatNumber'”

    So I have a suggested tweak to the script to cope with that…

    ‘ Display Volume percentage free instead of having to calculate from used and total
    ‘ Written by Jason Samuel (www.jasonsamuel.com) for use with BGInfo
    ‘ extra check to suppress with empty CD/DVD drives

    Set objWMIService = GetObject(“winmgmts:\\.\root\cimv2”)

    Set colDisks = objWMIService.ExecQuery _
    (“Select * From Win32_LogicalDisk”)

    For Each objDisk in colDisks
    intFreeSpace = objDisk.FreeSpace
    intTotalSpace = objDisk.Size
    pctFreeSpace = intFreeSpace / intTotalSpace
    intUsed = intTotalSpace – intFreeSpace
    if (intTotalSpace>0) then
    if FormatNumber(intTotalSpace / 1024 ^ 3,0) = “0” then

    else
    ‘ wscript.echo
    echo objDisk.DeviceID & ” ” & Right(Space(4) & FormatPercent(pctFreeSpace,0), 4) & ” ” & _
    Right(Space(6) & FormatNumber(intFreeSpace / 1024 ^ 3, 0),6) & “GB / ” & _
    Right(Space(6) & FormatNumber(intTotalSpace / 1024 ^ 3,0),6) & “GB”
    end if
    end if
    Next

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Apache

Today I would like to go over proper URL redirection when using SSL but first I would like to preface this by describing what...

Exchange 2003

A useful Exchange 2003 guide I wrote for a friend’s blog originally but I am posting it here on mine now for your viewing...

Citrix Workspace

You can use FIDO2 hardware security keys plugged into your physical desktop over the Citrix HDX remoting protocol for use with virtualized Windows Desktop...

Cloud Design Architecture

The community-driven paperback book initiated by my friends Bas van Kaam and Christiaan Brinkhoff is available for sale on Amazon. If you haven’t picked...

JasonSamuel.com was launched in 2008 as a platform to give back to the IT community by sharing knowledge and expertise. Over the years, it has become a trusted global resource for the latest insights, how-to guides, and forward-thinking leadership on enterprise mobility, security, virtualization, cloud architecture, automation, and other cutting-edge technologies. Today, it serves as a go-to reference hub for IT professionals, attracting hundreds of thousands of unique visitors from around the world each month. Learn more on the About Me page.
Copyright © 2008-2025 JasonSamuel.com

Exit mobile version