Tag Archives: WMI

Get a Drive’s Name/Label Using WMI in VBA

Doing my daily rounds, checking various forums to see if there were any interesting nuggets of knowledge, I came across a question on UtterAccess

 

Since, I’ve previously done much work retrieving all sorts of PC related information I figured I quickly help Raheel out and at the same time, post the code here for all to benefit.
 
Continue reading

VBA – WMI – Gather Information & Configure Printers Cont’d

So, I’ve recently been on a WMI Printer kick! 🙂

So let’s do one more article and share a little more of some of what can be done, things like:

  • Get Information About The Printer And Drivers
  • Get The PC’s Default Printer
  • Set A Printer As The Default Printer
  • Rename A Printer

 
Continue reading

VBA – WMI – Change the ‘Use Printer Offline’ Property

Earlier in the week, I demonstrated that WMI can be use for more than just retrieve information about a PC.

What about configuring different aspects of your PC!  That’s right, WMI can do that too.
 
Continue reading

VBA – WMI – Deleting A Printer

Just a short post today to demonstrate how easy it is to delete a printer from a PC executing some simple WMI code via VBA.

If you follow my blog at all, by now you are fully aware that WMI can easily retrieve information regarding pretty much any aspect of your PC: Hardware, Software, Events, …, but it can do so much more. Did you know it can also make changes to your PC! It can install, configure and even delete pretty much anything as well. So let’s explore a first simple example, the printer.

Continue reading

VBA – Find Disk Drive By Name

Once upon a time, I was asked to help automate a process of copying files to an External Drive. The issue was that when they plugged the device (external drive) into various machines, the associated drive letter wasn’t always the same. They also didn’t want me to use the Drive’s Serial Number as the identifier in case it died and they needed to replace it.

Instead, the solution was to bind to the Drive’s name. This way, if ever the drive was switched, all they needed to do was rename it in the same manner and the process would continue to work.

Now that we knew what we wanted to do, the question then became how could we do so?!
 
Continue reading

WMI Errors Using Count, ItemIndex, …

I was recently doing some WMI work and trying to implement some code simplification to an existing routine, but the code, which I knew was valid, kept throwing an

Error -2147217386 – Invalid operation

when trying to use the ItemIndex method.

I did some troubleshooting and was amazed when something as simple as object set Count property was also failing and returning

Error -2147467259 – Unspecified error

Continue reading

VBA WMI Explorer

Over the years, I’ve posted all sorts of code samples using WMI to get all sort of information from a PC, things like:

and many, many more!

For fun, I put together a more generalized, what I’ve deemed ‘WMI Explorer’ code.  Basically, you pick the WMI NameSpace, and Class and then you can view all the associated properties.  I’ve even added the ability to export  the results to Excel.

Continue reading

Enumerating Registry SubKeys Using WMI in VBA

I was trying to help a user out in a forum get a listing of all the SubKeys of a specific registry Key and thought I’d share my solution here.

Per the usual, there are a number of different ways to read the registry, but I found that using WMI is very simple.

To simplify things, I added the use of a ‘RegistryClass’ Enum so you don’t need to remember the various registry class constants.

Enough talk, here’s the code!

Continue reading

Enumerating Registry Key Values Using WMI in VBA

I was trying to help a user out in a forum get a listing of Values from a specific registry Key and thought I’d share my solution here.

Per the usual, there are a number of different ways to read the registry, but I found that using WMI is very simple.

To simplify things, I added the use of a ‘RegistryClass’ Enum so you don’t need to remember the various registry class constants.

Enough talk, here’s the code!

Continue reading

Determine the Path of a Mapped Drive

Find Path

Today, I thought I’d briefly touch upon Mapped Drives to provide a couple important tools that any developer should have to properly, quickly and easily work with Mapped drives.

Mapped Drives

A mapped drive is just a shortcut to a drive that’s physically located on a different computer. LifeWire

It allows you to designate a local drive letter to an external resource.  For example, you could assign the Z: drive letter to a remote share \\SomeServerName\ShareName (UNC path)_.  This way the user doesn’t need to know the actual path and can simply use the Z: drive from Windows explorer.

The same principle is true when Linking Tables within a database, instead of using the full UNC path, they can simplify their lives, and simply used the Mapped drive instead.  That said, there have been issues in the past with Mapped drives with Access, and it is highly recommend that table links always be established with UNC or IP based path.  This is part of the reason for this article, to show how you can determine the full path from an existing Mapped Drive.

Determine the Path of a Mapped Drive Manually

Let’s look at a few techniques that can be used to manually determine the full path of a Mapped Drive.

Continue reading