Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object doesn't support this property or method

Status
Not open for further replies.

jouell

MIS
Nov 19, 2002
304
US
Microsoft VBScript runtime error '800a01b6' Object
doesn't support this property or method

when running :

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from Win32_Printer")

For Each objPrinter in colInstalledPrinters
objPrinter.Delete
'msgbox (objPrinter.name)
Next


got from here:


to Delete All Printers on a Print Server


Any ideas?

tks!
 
jouell,
This code works as is on my machine, Windows 2000. What are you running for OS? Do you have WMI installed?

fengshui_1998
 
2000 server sp2

"Currently, WMI is included when you install Microsoft Windows 2000" - so i must.

tks!
-john
 
Is the WMI Service started? I think it needs to be running to create the "winmgmts:" namespace in the file system.
 
it was not
but starting did not help
i know we're close!

tks!
-john
 
This error is caused by a typo:

objPrinter.Delete_ must be used. Note the trailing "_" character.

The script probably also needs to run as an admin or backup operator to avoid an 80041024 error (Provider not capable of operation).
 
no luck w/the _, either
i am an admin (local and domain)
anything else?
thanks!
-john
 
jouell, did you ever happen to find a solution to your problem? I get the exact same error on a Windows 2000 server running SP4. I have run the "versions" script from the Technet FAQ and have confirmed I have the recommended versions of WMI and VB and such.

I have double-checked and am using the exact code from this site:
I noticed that at least right now the script published at this link is slightly different than the one you list at the top of the thread. It looks like:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next

It looks like a permissions problem of some kind but I have tried running both as a domain user with local admin privs and also as the local admin account on the server itself.
 
WMI is good for some things, ADSI is better at others.
I prefer to use ADSI for printing issues on servers.

regards
richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top