Announcement

Collapse
No announcement yet.

Setting Printers for all users?

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

  • Setting Printers for all users?

    I want to set printers based on machine, not by user account, so I configure a printer under one account, but in the other account on the same machine, the printer is not created.

    Is there a way to create the printer for all user accounts on a machine at the same time?

    Details: I am trying to use psexec to call a wscript vbs for all machine. I have a domain policy for printers but I don't want to have to ask everyone to log off and back on just for this, so I'm trying to push it out.

    I can use psexec to remotely run the script, but it's running as administrator and the user's printers don't change.

    So back to my original question, is there a way to create/delete printers for all users on a machine at the same time?

  • #2
    Re: Setting Printers for all users?

    What you'll find is that it is installing a network printer and that is not common among all users.

    What you will need to do is to create a new local port and map the printer to that. That way all users will get the printer.

    Comment


    • #3
      Re: Setting Printers for all users?

      or run a login script?
      I'm busy with such a script over here:
      http://forums.petri.com/showthread.php?t=14014
      Marcel
      Technical Consultant
      Netherlands
      http://www.phetios.com
      http://blog.nessus.nl

      MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
      "No matter how secure, there is always the human factor."

      "Enjoy life today, tomorrow may never come."
      "If you're going through hell, keep going. ~Winston Churchill"

      Comment


      • #4
        Re: Setting Printers for all users?

        hmmm, creating a new local port and then having all users map to that does not seem like an easy thing to do for everyone. In fact, it's worse from an automation point of view, especially since I've already got the wsh to map the network printers.

        It'll just be better to tell people to log off and back on if I can't find a way of remote executing for all users.

        Comment


        • #5
          Re: Setting Printers for all users?

          Originally posted by Dumber View Post
          or run a login script?
          I'm busy with such a script over here:
          http://forums.petri.com/showthread.php?t=14014
          when I click on that attachment I get the following error:
          Code:
          XML Parsing Error: not well-formed
          Location: chrome://mozapps/content/downloads/unknownContentType.xul
          Line Number 1, Column 6:C_URI(aPropertyString));
          -----^

          If you read the original post you might also remove those rolling eyes...

          I already have a basic script to map the printers. It is a logon script, but as I mentioned I wanted to be able to execute it throughout the enterprise without having to ask everyone to log off and back on again, we hate that since you have to close everything...

          Comment


          • #6
            Re: Setting Printers for all users?

            so you leave every computer 24 hours per day on?
            Printers are normally user based.

            ps, the attachment works
            Marcel
            Technical Consultant
            Netherlands
            http://www.phetios.com
            http://blog.nessus.nl

            MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
            "No matter how secure, there is always the human factor."

            "Enjoy life today, tomorrow may never come."
            "If you're going through hell, keep going. ~Winston Churchill"

            Comment


            • #7
              Re: Setting Printers for all users?

              yes unfortunately people leave their computers on all the time and have 20 things open, which is why they don't want to reboot or log on/off...

              Comment


              • #8
                Re: Setting Printers for all users?

                Originally posted by humbletech99 View Post
                yes unfortunately people leave their computers on all the time and have 20 things open, which is why they don't want to reboot or log on/off...
                How about using a script to restart the computers first?
                Code:
                shutdown /r /f /m \\computer_name /t 0
                Regards,
                Jeremy

                Network Consultant/Engineer
                Baltimore - Washington area and beyond
                www.gma-cpa.com

                Comment


                • #9
                  Re: Setting Printers for all users?

                  shutting the computers off isn't the problem

                  I would just tell people to log off and back on or reboot. I wanted to avoid the disruption to their processes.

                  Comment


                  • #10
                    Re: Setting Printers for all users?

                    Slighty sideways on this, but if the PCs are left on 24/7 (or at least 24/5) does management realise how much extra their power bill is by thes machines running 24 hours.
                    1 1 was a racehorse.
                    2 2 was 1 2.
                    1 1 1 1 race 1 day,
                    2 2 1 1 2

                    Comment


                    • #11
                      Re: Setting Printers for all users?

                      dunno, I will get them to switch off all their workstations eventually.

                      Comment


                      • #12
                        Re: Setting Printers for all users?

                        Well there is a way to add new printers remotely to the usersprofile w/out the need for them to logoff and back -on.

                        You have to Add the 'printer connection' to the key HKEY_CURRENT_USER\Printers\Connections\..., then the printer is visible for the currently Logged on user.

                        Here is a trick how you can remotely edit the HKEY_CURRENT_USER part of the registry!
                        (Each user’s HKEY_CURRENT_USER hive is really just a shortcut to a specific registry tree under HKEY_USERS. However, rather than listing users by name, users’ individual trees are identified by Security Identifier, or SID). You have to to determine the users SID first:
                        Code:
                        strInputFile = "C:\computers.txt"
                        
                        '*****************************************************************
                        '*           Get SID from currently logged-on DomainUser
                        '*****************************************************************
                        '\
                        'script: "RemoteEditRegistry.vbs"
                        'created on 7 march 07 by Remco Simons [nl]
                        '
                        ' This version 1.0
                        ' (http://forums.petri.com/showthread.php?t=14109)
                        'The script can only be runned by a member of the 'Domain Admins' group!
                        '/
                        
                        Const HKEY_CLASSES_ROOT     = &H80000000
                        Const HKEY_LOCAL_MACHINE    = &H80000002
                        Const HKEY_USERS            = &H80000003
                        
                        On Error Resume Next
                        
                         'Get the Computernames for processing from file (an other option would be a LDAP-query AD for computernames)
                           Set objController = CreateObject("WshController")
                           Set objFSO = CreateObject("Scripting.FileSystemObject")
                           Set objTSIn = objFSO.OpenTextFile(strInputFile)
                        
                           Do Until objTSIn.AtEndOfStream  '<---------------[begin loop, to process computers from list one-by-one]
                           strComputer = objTSIn.ReadLine
                        
                        
                           who = "winmgmts:{impersonationLevel=impersonate}!//"& strComputer &""
                           Set Users = GetObject( who ).InstancesOf ("Win32_ComputerSystem")
                        
                               for each User in Users
                                   strUsr    = right(User.UserName,len(User.UserName)-InStr(User.UserName,"\"))
                                   strDomain = left(User.UserName,InStr(User.UserName,"\")-1)
                                   exit For
                               next
                        
                           Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
                           set colAccounts = objWMIService.ExecQuery _
                               ("select * From Win32_UserAccount where name = '" & strUsr & "' AND domain = '" & strDomain & "'")
                        
                               For each objAccount in colAccounts
                                   strSID = objAccount.SID       
                                   exit For
                               Next
                        'You can now use the SID to edit the HKEY_USERS\{SID}-key of the logged-on Domain User...
                        '(you must end the main part of the script with: Loop [enter] objTSIn.Close )
                        '*****************************************************************

                        \Rem
                        Last edited by Rems; 7th March 2007, 20:10. Reason: Stript this version of the script to basic, added a complete version in next post

                        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


                        • #13
                          Re: Setting Printers for all users?

                          Here is the complete script to add a network printer to the usersprofile, while users are logged-on.

                          Code:
                          'Set variables ( remote installation -=Network Printers=- )
                          strPrintServer = "servername"
                          StrPrinterName = "displayname printer"  ' <--- display-name on the server!
                          sAsDefault = "yes"                            ' <--- choose "yes" or "no" if make it the default printer for the logged-on user.
                          
                          
                          strInputFile = "C:\computers.txt"
                          
                          '*****************************************************************
                          '*           Get SID from currently logged-on DomainUser
                          '*****************************************************************
                          '\
                          'script: "RemoteEditRegistry.vbs"
                          'created on 7 march 07 by Remco Simons [nl]
                          '
                          ' This version 1.0
                          ' (http://forums.petri.com/showthread.php?t=14109)
                          'The script can only be runned by a member of the 'Domain Admins' group!
                          '/
                          
                          Const HKEY_CLASSES_ROOT     = &H80000000
                          Const HKEY_LOCAL_MACHINE    = &H80000002
                          Const HKEY_USERS            = &H80000003
                          
                          On Error Resume Next
                          
                           'Get the Computernames for processing from file (an other option would be a LDAP-query AD for computernames)
                             Set objController = CreateObject("WshController")
                             Set objFSO = CreateObject("Scripting.FileSystemObject")
                             Set objTSIn = objFSO.OpenTextFile(strInputFile)
                          
                             Do Until objTSIn.AtEndOfStream  '<---------------[begin loop, to process computers from list one-by-one]
                             strComputer = objTSIn.ReadLine
                          
                          
                             who = "winmgmts:{impersonationLevel=impersonate}!//"& strComputer &""
                             Set Users = GetObject( who ).InstancesOf ("Win32_ComputerSystem")
                          
                                 for each User in Users
                                     strUsr    = right(User.UserName,len(User.UserName)-InStr(User.UserName,"\"))
                                     strDomain = left(User.UserName,InStr(User.UserName,"\")-1)
                                     exit For
                                 next
                          
                             Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
                             set colAccounts = objWMIService.ExecQuery _
                                 ("select * From Win32_UserAccount where name = '" & strUsr & "' AND domain = '" & strDomain & "'")
                          
                                 For each objAccount in colAccounts
                                     strSID = objAccount.SID       
                                     exit For
                                 Next
                          'You can now use the SID to edit the HKEY_USERS\{SID}-key of the logged-on Domain User...
                          '(you must end the main part of the script with: Loop [enter] objTSIn.Close )
                          '*****************************************************************
                          
                          
                          ' -=Add and connect the network printer=-
                          
                          Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
                          
                          'Parameters Key(4x) and values(5x)
                          
                          strKeyPath1 = strSID & "\Software\Microsoft\Windows NT\CurrentVersion\Devices"
                              ValueName1   = "\\" & strPrintServer & "\" & StrPrinterName
                          
                             '***Count the already installed 'net'port printers for the next available number
                              Set oMethod = objReg.Methods_("EnumValues")
                              Set oInParam = oMethod.inParameters.SpawnInstance_()
                          
                              oInParam.hDefKey = HKEY_USERS
                              oInParam.sSubKeyName = strKeyPath1
                          
                              Set oOutParam = objReg.ExecMethod_("EnumValues", oInParam)
                                           xCount = 0
                                  For i=0 To UBound(oOutParam.Properties_("sNames"))
                                      sName = oOutParam.Properties_("sNames")(i)
                                      objReg.GetStringValue HKEY_USERS,strKeyPath1,sName,dwValue
                                        If Not InStr(1,dwValue,"winspool,LPT",0) = 0 Then
                                              'LPT port
                                        ELSE 'Ne.. ports
                                          If sName = ValueName1 Then
                                              strValue1 = dwValue
                                          ELSE
                                              xCount = xCount + 1
                                          End If
                                        End If
                                  Next
                                     
                              sNe = "Ne"& 0&xCount &":"
                              If not strValue1 = dwValue then strValue1 = "winspool," & sNe
                          
                          
                          strKeyPath2 = strSID & "\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts"
                              ValueName2   = ValueName1
                                strValue2  = strValue1 & ",15,45"
                          
                          strKeyPath3 = strSID & "\Printers\Connections\,," & strPrintServer & "," & StrPrinterName
                              ValueName3a  = "Server"
                                strValue3a = "\\" & strPrintServer
                              ValueName3b  = "Provider"
                                strValue3b = "win32spl.dll"
                          
                          strKeyPath4 = strSID & "\Software\Microsoft\Windows NT\CurrentVersion\Windows"
                              ValueName4   = "Device"
                                strValue4  = ValueName1 & "," & strValue1
                          
                          
                          'Add the printer to the 'CURRENT'_USER's path
                          objReg.CreateKey HKEY_USERS, strKeyPath3
                          objReg.SetStringValue HKEY_USERS, strKeyPath2, ValueName2, strValue2
                          objReg.SetStringValue HKEY_USERS, strKeyPath1, ValueName1, strValue1
                          objReg.SetStringValue HKEY_USERS, strKeyPath3, ValueName3a, strValue3a
                          objReg.SetStringValue HKEY_USERS, strKeyPath3, ValueName3b, strValue3b
                          
                          'Make it the default printer Y/N?
                          If LCase(sAsDefault) = "yes" Then
                             objReg.SetStringValue HKEY_USERS, strKeyPath4,ValueName4, strValue4
                          End If
                          
                          
                          Loop            
                          objTSIn.Close        '<--- End of list computernames, close InputFile 
                          
                          On Error GoTo 0
                          
                          wscript.echo "Done!"
                          wscript.quit
                          \Rem
                          Last edited by Rems; 7th March 2007, 20:38.

                          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