Click here to Skip to main content
13,055,408 members (53,153 online)
Rate this:
Please Sign up or sign in to vote.
Greetings everybody,

I'm trying to install a network printer using an administrator user but I'm getting the error message (Operation couldn't be completed error 0x00000032), when I searched for this error message I found that it means that the user is not authenticated to install the printer but I'm sure the user is admin and the password is correct.

The scenario is:
1-Open a network connection to the NAS storage using username & password to be able to read the printers drivers.
2-Create TCP/IP Port using domain admin user.
3-Install the printer using domain admin user.

The Code:
public Form1()
//Open Connection to NAS Storage when form loads >> Step 1
            ProcessStartInfo P = new ProcessStartInfo();
            P.FileName = "net";
            P.Arguments = "use \"\\\\\\CIB Library\" /user:username password";
            P.CreateNoWindow = true;
            P.UseShellExecute = false;
private void Test_Click(object sender, EventArgs e)
//Using Credentials
            SecureString password = new SecureString();
            foreach (char c in "xyz") password.AppendChar(c);
//Create Printer TCP/IP port >> Step 2
            ProcessStartInfo info = new ProcessStartInfo();
            info.FileName = "cscript";
            info.Arguments = @"c:\Windows\System32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r IP_10.17.10.176 -h -o raw";
            info.UserName = "username";
            info.Password = password;
            info.Domain = "domain";
            info.UseShellExecute = false;
            info.CreateNoWindow = true;
//Install the printer >> Step 3
            string _systemRoot = Environment.GetEnvironmentVariable("SYSTEMROOT");
            string _system32 = Environment.GetEnvironmentVariable("SYSTEMROOT") + @"/System32";
            info.WorkingDirectory = _system32;
            info.FileName = _system32 + @"/RUNDLL32";
            info.Arguments = "printui.dll, PrintUIEntry /if /b \"HP LaserJet 4250n\" /f \"\\\\\\CIB Library\\Drivers\\Printers XP\\HP\\HP 4250 CD\\Drivers\\i386(32 bit - 2000_XP_S2003_Vista)\\PS\\hpc4x50d.inf\" /r \"IP_10.17.10.176\" /m \"HP LaserJet 4250 PS\"";
            info.UserName = "username";
            info.Password = password;
            info.Domain = "domain";
            info.UseShellExecute = false;
            info.CreateNoWindow = true;

I think the problem is a conflict between the domain credentials I use in the printer installation part of the code and the credentials used to connect to the NAS storage where the printer driver locates because I have no problem creating the TCP/IP port or installing printers using local stored drivers.

I hope this makes it easier for you to solve my problem

Thanks in advance for your help
Posted 22-Apr-12 0:03am
Updated 22-Apr-12 4:01am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


interesting problem, not easy to find a solution from outside of your enviroment.
Maybe some ideas to solve your problem:

Take care of your os when using printui.dll (althought you wrote it works with local stored drivers):

Win2000/Server 2003:[^]


Win7/Vista/Server 2008:[^]

It would be a great help to know where it exactly stucks, if it's "only" at step 3 of your code, there must be something wrong with credentials/arguments of printui.dll/filepath to your INF. A quick check if it works to get some "normal" file using a process would give a good return if it could be a problem with credentials. Then you're able to try the rest.
In addition I would going safe if Step2 was finished successfully (maybe give Step2 a little time to create port).

Hope that helps.

A.Rahman Seyam 24-Apr-12 2:47am
Hi Bjorn

Thanks very much for your reply, I'm aware of the location of the printui.dll file and I tested this command already on CMD and worked fine on my PC (Windows7) even when I remove the credentials part of my code and run it on an administrator user it works fine and installs the printer, I'm pretty sure that the problem is in the credentials part in step3
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I found the solution of my problem by creating a user account on the NAS storage with the same account name and password of my domain user, also joining the NAS storage to the domain would work.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 4 May 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100