Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 954477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:13:19+00:00 2026-05-16T00:13:19+00:00

I am working on project for controlling some devices through lpt port. I am

  • 0

I am working on project for controlling some devices through lpt port.
I am using inpout32.dll to get raw access to ports and now trying to enumerate all available LPT ports and get their I/O Range.

I now I can check device manager, but is there any more automated way?

Now I am trying to use WMI some sample code that should work but it does not

Set wmiService = GetObject("winmgmts:\\.\root\cimv2")

Set parallelports = wmiService.ExecQuery("SELECT * FROM Win32_ParallelPort")                      

For Each port In parallelports
    q = "SELECT * FROM Win32_PnPEntity WHERE PNPDeviceID = '" & port.PNPDeviceID & "'"
    Set pnpentities = wmiService.ExecQuery(q)

    For Each pnpentity In pnpentities
        wscript.echo pnpentity.PNPDeviceID
    Next
Next

on line ‘For Each pnpentity In pnpentities’ I get error.
Also I am not shure if finding corresponding entity will help me.

PS.
Finally i figured out how to enumerate lpt i/o port ranges.

Set wmiService = GetObject("winmgmts:\\.\root\cimv2")

Set parallelports = wmiService.ExecQuery("SELECT * FROM Win32_ParallelPort")

For Each port In parallelports
    Set port_resources = wmiService.ExecQuery("ASSOCIATORS OF {Win32_ParallelPort.DeviceID='" & port.DeviceID & "'} WHERE ResultClass = Win32_PortResource")

    For Each port_resource In port_resources
        wscript.echo port_resource.Caption
    Next
Next
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:13:19+00:00Added an answer on May 16, 2026 at 12:13 am

    You get an error because PNPDeviceID contains backslashes (\) and backslashes in WQL queries must be doubled. Just do a replace of \ with \\ in port.PNPDeviceID before inserting it into your query, and your script will work fine:

    strPNPDeviceID = Replace(port.PNPDeviceID, "\", "\\")
    Set pnpentities = wmiService.ExecQuery( _
        "SELECT * FROM Win32_PnPEntity WHERE PNPDeviceID = '" & strPNPDeviceID & "'")
    

    You may also find this question useful: How to find available parallel ports and their I/O addresses using Delphi and WMI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm copying some objective c++ files over from another (working) project. I get no
While working a project tonight, I ended up using one .js resource file for
I'm currently working on project with Haskell, and have found myself some trouble. I'm
I'm working on project that lets users choose some scientific authors and columnists and
I'm working on a project that involves controlling of multiple wheeled robots (running .NET
I've started using Mercurial for version-controlling my Drupal project source files (I'm both a
I am working on a robotic project, that involves controlling the position of a
I'm currently editing a working project with some experience on PHP. I know a
I am working on a VC++ project under VS2008. My resource files contain some
I had a working project in VS2008 / .Net 3.5 using controls from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.