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 4570844
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:25:11+00:00 2026-05-21T19:25:11+00:00

How can I detect what port (Ne01:, Ne02:, Ne99: etc) the printer is on?

  • 0

How can I detect what port (Ne01:, Ne02:, Ne99: etc) the printer is on?

Computers (WinXP) here at BigCorp have Adobe Acrobat (version 7.0 Pro) installed which gives a virtual printer named “Adobe PDF”. If you print an Excel (2003) workbook to pdf while recording a macro, the printer’s full name is “Adobe PDF on Nexx:” where xx is a double digit…. and differs depending on what computer you try.

I have written a C# console app using the Excel.Interop (I strongly discourage anyone else from starting down this road to hell) that opens a series of spreadsheets. It runs a macro in each one, saves, prints is as a pdf, then moves the pdf to a reports folder on a shared drive.

The problem I face is that every install of Acrobat seems to pick a random port number for the PDF printer… and I can’t figure out how to get it.

So far I have tried using the Win32_Printer class like so

var searcher = new ManagementObjectSearcher( @"SELECT * FROM Win32_Printer" );
foreach ( ManagementObject printer in searcher.Get() )
{
   if ( Regex.IsMatch( printer["Name"].ToString(), @"(adobe|pdf)", RegexOptions.IgnoreCase ) )
   {
       //printer["Name"];    => "Adobe PDF"
       //printer["PortName"] => "my documents/*.pdf"
       foreach ( PropertyData pd in printer.Properties )
       {
           Console.WriteLine(string.Format("{0}, {1}", pd.Name, pd.Value));
       }
           break;
      }
}

I also poked around in the System.Drawing.Printing class. The PrinterSettings.InstalledPrinters will give you the name of the printer “Adobe PDF” but I can’t figure out how to get the port info.

If I pass just “Adobe PDF” to the excel interop PrintOut() method it sometimes works and sometimes fails with “Document failed to print”… I cannot figure out why.

If I pass a hardcoded “Adobe PDF on Ne0x:” with an appropriate x value it works every time.

If I try every possible variation, Excel helpfully prints to the default printer. I do not have the option of changing the default printer (security policy restriction)

Can anyone point me to code that correctly pulls the printer port?

  • 1 1 Answer
  • 0 Views
  • 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-21T19:25:12+00:00Added an answer on May 21, 2026 at 7:25 pm

    Here’s what I ended up doing

    using Microsoft.Win32;
    ...
    
            var devices = Registry.CurrentUser.OpenSubKey( @"Software\Microsoft\Windows NT\CurrentVersion\Devices" ); //Read-accessible even when using a locked-down account
            string printerName = "Adobe PDF";
    
            try
            {
    
                foreach ( string name in devices.GetValueNames() )
                {
                    if ( Regex.IsMatch( name, printerName, RegexOptions.IgnoreCase ) )
                    {
                        var value = (String)devices.GetValue( name );
                        var port = Regex.Match( value, @"(Ne\d+:)", RegexOptions.IgnoreCase ).Value;  
                        return printerName + " on " + port;
                    }
                }
            }
            catch
            {
                throw;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I almost sure that PHP can't detect the View port size of a browser
I have to detect port aggregation configuration on Linux. Supposing that the ifcfg-* files
I have a piece of code that can read current state of serial port
I have the following code and I want to detect in which port client
I can detect that app is running under iOS Simulator (using sysctlbyname(hw.machine) ), but
I can detect my iPad device running an iPhone app in 1x or 2x
Is there anyway I can detect via jQuery if a select form element is
I know that richtextboxes can detect links (like http://www.yahoo.com ) but is there a
I want to build flash application that can detect the user eyes color and
Is there any way that you can detect the resizeHandlers moment of completion? something

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.