Announcement

Collapse
No announcement yet.

VB script to map printer!! Need Help!!

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • VB script to map printer!! Need Help!!

    Hi all,

    I'm newly joined to this forum.Looking forward to learn more cool stuffs from experts..

    I got an issue now...need all ur help.i wrote a basic Vb script to map network printer for XP Home edition.however it requires username and password. how and what command to edit in my current script.Below is my basic vb script.

    Dim objNetwork, strUNCPrinter
    strUNCPrinter = \\servername\printername
    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.AddWindowsPrinterConnection strUNCPrinter

    Please assist.Thank alots.!!

  • #2
    Re: VB script to map printer!! Need Help!!

    Hi Ahtshun,

    If you want to add n/w printer then copy past below matter in notepad & save it with .vbs extension also change the required data like ip address & printer name


    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.AddWindowsPrinterConnection "\\192.168.20.21\HPLJ4345 "


    => 192.168.20.21 is ip address of printer server & HPLJ4345 is name of the shared printer.
    I tried this & it is working fine. it is not asking any id or password.

    Comment


    • #3
      Re: VB script to map printer!! Need Help!!

      Originally posted by ahtshun
      Dim objNetwork, strUNCPrinter
      strUNCPrinter = \\servername\printername
      Set objNetwork = CreateObject("WScript.Network")
      objNetwork.AddWindowsPrinterConnection strUNCPrinter
      Just curious, but are you tying to run XP Home on a network with an actual Server or is the PC that the printer is connect to just called Server?

      If you are still having problems with this script, please provide us some details of the network setup that you are trying to get this script running from. Ta.
      1 1 was a racehorse.
      2 2 was 1 2.
      1 1 1 1 race 1 day,
      2 2 1 1 2

      Comment


      • #4
        Re: VB script to map printer!! Need Help!!

        what about that?
        I use that as *.bat file in netlogon, but it's quite usefull.

        rundll32 printui.dll,PrintUIEntry /in /n \\servername\printername
        ..:: jumanji

        Comment


        • #5
          Re: VB script to map printer!! Need Help!!

          strPrinter="\\Server\Printer"
          Set WshNetwork = CreateObject("WScript.Network")
          Set WshShell = CreateObject("WScript.Shell")
          WshNetwork.AddWindowsPrinterConnection strPrinter
          WshNetwork.SetDefaultPrinter strPrinter

          MsgBox strPrinter & " Printer connected and set as the default printer"
          Set WshNetwork = WScript.CreateObject("WScript.Network")

          Comment


          • #6
            Re: VB script to map printer!! Need Help!!

            The OP provided us no further information about the type of network and printserver to be able to help him/her with the question.

            The samples contributed so far, all of them are fine include ahtshun's own script. But, IMHO none of them is a solution or help for the issue that ahtshun described.
            i wrote a basic Vb script to map network printer for XP Home edition.however it requires username and password. how and what command to edit in my current script.

            \Rems

            This posting is provided "AS IS" with no warranties, and confers no rights.

            __________________

            ** Remember to give credit where credit's due **
            and leave Reputation Points for meaningful posts

            Comment


            • #7
              Re: VB script to map printer!! Need Help!!

              sorry for the late reply..

              anyway,i managed to solve it by all ur suggestions/helps..thank you very much

              Comment


              • #8
                Re: VB script to map printer!! Need Help!!

                ahtshun, could you post the working script back here so others may benefit from it in the future. It would be greatly appreciated. Thanks.
                1 1 was a racehorse.
                2 2 was 1 2.
                1 1 1 1 race 1 day,
                2 2 1 1 2

                Comment

                Working...
                X