Search This Blog

Thursday, January 21, 2010

Using WMI To query for App-V Packages



Here's a bit of code to query WMI for App-V Packages:


string root = "root/microsoft/appvirt/client";
ManagementPath path = new ManagementPath(root);
ManagementScope scope = new ManagementScope(path);

// Try and connect to the remote (or local) machine.
try
{
scope.Connect();
}
catch (ManagementException ex)
{
// Failed to authenticate properly.
return "Failed to authenticate: " + ex.Message;
//p_extendederror = (int)ex.ErrorCode;
//return Status.AuthenticateFailure;
}
catch (System.Runtime.InteropServices.COMException)
{
// Unable to connect to the RPC service on the remote machine.
return "Unable to connect to RPC service";
//p_extendederror = ex.ErrorCode;
//return Status.RPCServicesUnavailable;
}
catch (System.UnauthorizedAccessException)
{
// User not authorized.
return "Error: Unauthorized access";
//p_extendederror = 0;
//return Status.UnauthorizedAccess;


}
ManagementScope wmiScope = scope;
ObjectQuery oq = new ObjectQuery("Select * from Package");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmiScope, oq);

foreach (ManagementObject queryObj in searcher.Get())
{
ListManagementObject> appvPackages = new ListManagementObject>();
appvPackages.Add(queryObj);
}


You now have a generic List of Managementobjects that contains all sorts of information about the App-V packages.


Here's an example what kind of information is in one ManagementObject:



As you can see, almost everything you need to know is in here.












Not Everything! But I will blog about that later...

App-V Self Support Tool

Yesterday Jeroen (my collegue) and I released the App-V Self Support Tool.

Read the article about the release on BrianMadden

In the coming days, I'll give you peeks under the hood of this application, so you can write something like this yourself.

Here's a picture:

A new blog!

Hi All,

THis is the start of me new blog!

Cheers,
Peter Nap