'VBScript - Invalid Syntax for WMI Query

I am using VBScript to interact with WMI and check whether any print jobs are outstanding. When I run the query using VBScript I get the following error:

enter image description here

I've used the code on other machines and it works correctly. The code I'm using is:

Set objWMIService = GetObject("winmgmts: {impersonationlevel=impersonate}!\\.\root\cimv2")
Set colPrintJobs = objWMIService.ExecQuery("SELECT * FROM Win32_PrintJob")

Unsure about how to proceed as I'm confident it's not actually a syntax error but rather something that's wrong with WMI. WMI looks to be OK but I could be missing something. Any help would be appreciated!

OS - Windows 10 Enterprise, Version 20H2



Solution 1:[1]

Turns out the issue was being caused by an issue with 32-bit WMI. I ran the script using 64-bit wscript and it worked fine.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RuffMingani