Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
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:
C#
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
Updated 22-Apr-12 4:01am
v2

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
 
Share this answer
 
v2
Comments
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
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
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900