Problem installing network printers using drivers stored on a NAS storage

Answered Problem installing network printers using drivers stored on a NAS storage

  • Wednesday, April 18, 2012 2:31 PM
     
      Has Code

    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



All Replies

  • Thursday, April 19, 2012 9:21 AM
    Moderator
     
     

    Hi Abdel,

    We’re doing research on this issue. It might take some time before we get back to you.


    Bob Shen [MSFT]
    MSDN Community Support | Feedback to us

  • Tuesday, April 24, 2012 8:59 AM
     
     

    What if you try the 3 steps (command or script) within a command window, can you install the printer successfully? if the operation still fail with similar error, you may try TechNet forum for further support.

    If step 3# depends on step 2#, you can wait for exit of the 2nd process before start the 3rd process, Process.WaitForExit() method can fit this need.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Regards,
    Eric Yang
    Microsoft Online Community Support

  • Tuesday, April 24, 2012 12:39 PM
     
     

    Thanks Eric very much for your reply,

    I tried this command on CMD first and it worked successfully also this code works fine if I removed the credentials part from the code and run it on administrator user.you may be right that I need some delay between step2 and step3 to finish creating the TCP/IP port but still I have problem installing the printer using different credentials.

    Thanks

  • Tuesday, May 01, 2012 1:26 AM
     
     

    Hi Abdel,

    Sorry for the late reply, seems the email notification system is not very stable.

    This issue sounds to be related to UAC: even though a process is running under administrator user account, the process can only perform limited operation because it is running under standard privileges, to occupy all privileges of an administrator, we need to run the application as administrator (right-click the executable, and select "run as administrator"), user will be popped up a UAC dialog to make the decision whether allow a program to acquire admin privilege. 

    When start a new process in C#, you can use "runas" as its ProcessStartInfo.Verb property, then the application will "run as administrator", and, there will be a UAC dialog pop up.

     proc.Verb = "runas";


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Regards,
    Eric Yang
    Microsoft Online Community Support

  • Friday, May 04, 2012 11:13 AM
     
     Answered
    Thanks Eric for your reply, actually 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