WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WMI
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WMI Query Paths Need Double Backslashes

 Keywords: WMI WQL Query Backslash Paths 

Question:

I am playing around with WMI today. For a longest time, I couldn’t get this query to work.
colFiles = objWMIService.ExecQuery ("SELECT * FROM Win32_PageFileUsage WHERE Name = 'C:\pagefile.sys'")
Any Ideas?

Answer:

The problem is how you are specifying the Path! You will need to use double back slash instead of single back slash. The correct query should look like this:
colFiles = objWMIService.ExecQuery ("SELECT * FROM Win32_PageFileUsage WHERE Name = 'C:\\pagefile.sys'")
Note the use of single quotes to specify strings and double backslashes in place of each backslash. These are required conventions of WMI.
Article ID:   W17502
File Created: 2008:04:10:15:11:40
Last Updated: 2008:04:10:15:11:40