Announcement

Collapse
No announcement yet.

How to map printers in a workgroup using scripts

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

  • How to map printers in a workgroup using scripts

    Hi all..

    I am completely new to scripting...Currently I am setting up the servers for an office but we are working in a workgroup environment as a makeshift arrangement.Everyday I have to map the shared printers for users induvisually as they lose mapping after a day or two..

    Is it possible to map the printers through scripts for respective users remotely or may be users can run a specific script each day they login?

    I repeat this a workgroup and we donot have a domain currently..

    If there is a way please let me know...

    Thanks in advance


    Fazal
    Fazal Zaidi
    MCITP-Windows 2008,Exchange 2010,MCTS-Exchange 2007,2010,Lync 2010,MCSE-2000,2003,MCSA-2003,2008,2012,MCP,MCSE -Messaging 2013,ITIL

  • #2
    Re: How to map printers in a workgroup using scripts

    This must not happen "they lose mapping after a day or two". You seem to have a problem. But anyway, Have a look at THIS PAGE

    Comment


    • #3
      Re: How to map printers in a workgroup using scripts

      Code:
      Set WshNetwork = CreateObject("WScript.Network")
      
      WshNetwork.AddWindowsPrinterConnection "\\Server\printersharename"
      WshNetwork.SetDefaultPrinter "\\server\printersharename"
      • Copy the above code, paste into a notepad,
      • Make the relevant changes in the \\Server\Printersharename section,
      • Change server to the computername where the printer is installed and printersharename,
      • Save it as VBS in the following folder: C:\Documents and Settings\all users\Start Menu\Programs\Startup

      The above script will add a printer connection and set that printer as the default.
      When you place the script in the startup folder for all users, it'll run when anyone logs on to that machine.
      If you don't want it as the default printer then take the following line off the script.
      Code:
      WshNetwork.SetDefaultPrinter "\\server\printersharename"
      Cheers
      Caesar's cipher - 3

      ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

      SFX JNRS FC U6 MNGR

      Comment


      • #4
        Re: How to map printers in a workgroup using scripts

        Dear L4ndy

        Thanks for the reply...I tested the script but for some reason it errors out.I am pasting the error code

        ---------------------------
        Windows Script Host
        ---------------------------
        Script: C:\Documents and Settings\All Users\Start Menu\Programs\Startup\as.vbs
        Line: 3
        Char: 1
        Error: Permission denied
        Code: 800A0046
        Source: Microsoft VBScript runtime error

        ---------------------------
        OK
        ---------------------------


        I also checked another script which gives the same error code...I will paste that script also

        Option Explicit
        Dim objNetwork
        Dim strUser, strPassword, strUNCPrinter

        ' Values of variables set
        strUNCPrinter = "\\server1\Lexmark"
        strUser = "guytom"
        strPassword = "<password removed by MOD>
        Set objNetwork = WScript.CreateObject("WScript.Network")
        objNetwork.AddWindowsPrinterConnection strUNCPrinter, strUser, strPassword

        WScript.Echo "Script finish, Check printer"
        WScript.Quit


        Please help!

        Regards

        Fazal
        Last edited by Dumber; 8th July 2008, 11:18.
        Fazal Zaidi
        MCITP-Windows 2008,Exchange 2010,MCTS-Exchange 2007,2010,Lync 2010,MCSE-2000,2003,MCSA-2003,2008,2012,MCP,MCSE -Messaging 2013,ITIL

        Comment


        • #5
          Re: How to map printers in a workgroup using scripts

          Your problem is happening because is no enough rights "Error: Permission denied". Try to share "Startup" folder, and give everyone read rights both in "Sharing" and "NTFS". And you should also remember that normal users can't install printers or anything. So if the sharing didn't work, add a test user to "Power Users" group and login with it and check whether you receive that error message or not.

          Comment


          • #6
            Re: How to map printers in a workgroup using scripts

            Originally posted by John2008 View Post
            Your problem is happening because is no enough rights "Error: Permission denied". Try to share "Startup" folder, and give everyone read rights both in "Sharing" and "NTFS". And you should also remember that normal users can't install printers or anything. So if the sharing didn't work, add a test user to "Power Users" group and login with it and check whether you receive that error message or not.
            I don't think the problem is with the Startup folder, and I wouldn't recommend sharing it. The everyone group has got read and execute permisson on the folder by default and the fact that the script returned the error below, means that it has been executed.

            Fazal,
            Have you changed the printer share and security permission on the server by any chance?
            Can you make sure the user who wants to add the printer connection has got the right security and share permissions on the Printer.
            Last edited by L4ndy; 8th July 2008, 08:40.
            Caesar's cipher - 3

            ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

            SFX JNRS FC U6 MNGR

            Comment


            • #7
              Re: How to map printers in a workgroup using scripts

              Originally posted by L4ndy View Post
              Can you make sure the user who want's to add the printer connection has got the right security and share permissions on the Printer.
              Good Point

              Comment


              • #8
                Re: How to map printers in a workgroup using scripts

                Originally posted by John2008 View Post
                Originally posted by L4ndy View Post
                Can you make sure the user who wants to add the printer connection has got the right security and share permissions on the Printer.
                Good Point
                FYI
                In a workgroup environment the users bind to other computers by using the Guest account on the server.
                If the Guest account is not enabled then you must synchonize Usernames and Password on both computers. You can not use blank passwords!


                This article shows how an administrator can map a networkprinter for All Users;


                \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

                Working...
                X