Get error trying to list published printers in AD

Posted on 2004-11-15
Last Modified: 2010-05-18
following script errors on line 13
table does not exist    code 80040E37

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT printerName, serverName FROM " _
 & " 'LDAP://DC=landam,DC=com' WHERE objectClass='printQueue'"
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
 Wscript.Echo "Printer Name: " & objRecordSet.Fields("printerName").Value
 Wscript.Echo "Server Name: " & objRecordSet.Fields("serverName").Value
Question by:garylouis
    LVL 3

    Expert Comment

    which is line 13? looks to me like you have line wrap on.

    Author Comment

    objCommand.CommandText = "SELECT printerName, serverName FROM " _
     & " 'LDAP://DC=landam,DC=com' WHERE objectClass='printQueue'"

    figured it out should be

    objCommand.CommandText = "SELECT printerName, serverName FROM " _
     & " 'LDAP://DC=landam,DC=landamerica,DC=net' WHERE objectClass='printQueue'"

    used following to figure out -

     Get Domain name from RootDSE object.
    Set objRootDSE = GetObject("LDAP://RootDSE")
    strDomain = objRootDSE.Get("DefaultNamingContext")

    WScript.Echo strDomain ' This is Extra line Guy put in to test

    found on a great script error site -

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now