Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# install Errors Printer
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()
        {
 
            InitializeComponent();
 
//Open Connection to NAS Storage when form loads >> Step 1
            ProcessStartInfo P = new ProcessStartInfo();
            P.FileName = "net";
            P.Arguments = "use \"\\\\10.11.3.133\\CIB Library\" /user:username password";
            P.CreateNoWindow = true;
            P.UseShellExecute = false;
            Process.Start(P);
           
        }
 
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 10.17.10.176 -o raw";
            info.UserName = "username";
            info.Password = password;
            info.Domain = "domain";
            info.UseShellExecute = false;
            info.CreateNoWindow = true;
            Process.Start(info);
 
//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 \"\\\\10.11.3.133\\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;
            Process.Start(info);
}
 
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 1:03am
Edited 22-Apr-12 5:01am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
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:
http://support.microsoft.com/kb/189105[^]
 
XP:
http://support.microsoft.com/kb/314486[^]
 
Win7/Vista/Server 2008:
http://technet.microsoft.com/de-de/library/ee624057%28v=ws.10%29.aspx[^]
 
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.
 
Regards
  Permalink  
v2
Comments
A.Rahman Seyam at 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
good
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.
 
Thanks
  Permalink  
v2

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

  Print Answers RSS
0 DamithSL 265
1 CPallini 235
2 OriginalGriff 233
3 Maciej Los 195
4 George Jonsson 170
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 4 May 2012
Copyright © CodeProject, 1999-2014
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