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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:29:08+00:00 2026-06-04T10:29:08+00:00

I have an executable that installs a printer driver, and then creates a printer

  • 0

I have an executable that installs a printer driver, and then creates a printer using said driver. I use a tlbimp generated managed version of prnadmin from the server 2003 resource kit.

On windows XP, I have to set the print processor to MS_XPS. The default processor is WINPRINT. This snippet is what does that.

  static string winxpPrinterProcessor = "MS_XPS";
  if (isWinXP() && pPrinter.PrintProcessor != winxpPrinterProcessor)
  {
    Console.WriteLine("Oh No, the printer exists, but the processor isn't XPS. Setting now. It's currently " + pPrinter.PrintProcessor);
    pPrinter.PrintProcessor = winxpPrinterProcessor;
    Console.WriteLine("Set the processor to " + winxpPrinterProcessor);
    if (updateOnly)
    {
      pMaster.PrinterSet(pPrinter);
    } else { //else we're adding
      pMaster.PrinterAdd(pPrinter);
    }

When running the program myself, by double clicking, it works perfectly. When running it as a MSI Custom Action, it doesn’t work. Everything works (installing the printer, driver, setting the port) but setting the print processor. Windows just ignores the processor setting.

The MSI launches the custom action (it’s a console app) process as the SYSTEM user. When I manually launch it it’s running under my Domain Admin account.

I should also note that installing the printer manually works fine as well because xp picks up the processor from the INF file. It ignores that setting when using the prnadmin dll.

I’ve had a very frustrating morning. Any thoughts? Or better ways to install a printer?

  • 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-06-04T10:29:10+00:00Added an answer on June 4, 2026 at 10:29 am

    Okay, never figured out why it failed in that specific case, but I did figure out a much better work around. If somebody can answer my original question I’ll give you the answer.

    background: we chose to do everything with the prnadmin wrapper because we had to create a port and that seemed the easiest way to do that.

    Instead of creating the printer with managed code as well we now shell out commands to PrintUI. We can set the port with PrintUI and windows XP will pick up the processor specified in the INF file when using PrintUI, so it kills 2 birds with one stone.

    public static string PrinterDriverName = "MyPrinter.INF";
    public static string portOutputFileName = "nul:";
    
    /// <summary>
    /// Installs a printer and driver from an INF file, setting the 
    /// port to portOutputFileName ('nul:' in this case)
    /// </summary>
    private static void CreatePrinterPrintUI()
    {
      string sCommand = String.Format(@"rundll32 printui,PrintUIEntry /if /K /m '{0}' /n '{0}' /r '{2}' /f '{1}'"
        ,PrinterDriverName,Path.Combine(Application.StartupPath,PrinterDriverInf)
        ,portOutputFileName).Replace("'","\""); //it fails on single quotes
      execCmd(sCommand);
    }
    
    public static void execCmd(string _sCmd)
    {
      try
      {
        System.Diagnostics.ProcessStartInfo p = new ProcessStartInfo("cmd", "/c " + _sCmd);
        p.RedirectStandardOutput = true;
        p.UseShellExecute = false;
        p.CreateNoWindow = true;
        System.Diagnostics.Process proc = new System.Diagnostics.Process();
        proc.StartInfo = p;
        proc.Start();
        string sResult = proc.StandardOutput.ReadToEnd();
        Console.WriteLine(sResult);
      }
      catch (Exception e)
      {
        sErr += e.ToString();
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built an executable shell that using MEF loads assemblies (MEF Parts) and
I have a server executable that talks to Active Directory to retrieve user information.
I have a product setup executable that copies some files to the user's hard
we have a VB6 binary executable that comes with no source code. And we
Lets say that I have an executable and when it is started I want
I have an executable jar Client.jar that requires jndi.properties file. Since the jndi properties
I want to ignore executable files that do not have an extension For example:
I'm trying to pass files one by one(I have to dot that since executable
I have some scripts that are supposed to be executable. But after it is
I have a Mojolicious Lite script that gives out an executable file (user can

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.