Announcement

Collapse
No announcement yet.

Setting Default Printer using a VBS script through a GPO

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

  • Setting Default Printer using a VBS script through a GPO

    Hi All, I am trying to set a Default printer on a bunch of PCs in a lab using a VBS script through a GPO. I have tried several configs "putting the script in the Computer side, the User side of Logon and/or Start-Up scripts in the GPO. I can run the script from "run" command on the computers and it works fine, setting a certin printer as default, but nothing happens when it run through the GPO.. any help would be great..thanks.......m
    here is the script:
    Dim Net
    Dim WSHShell

    Set WSHShell = WScript.CreateObject("WScript.Shell")
    Set Net = CreateObject("WScript.Network")

    Net.SetDefaultPrinter "\\sscsbackup\Dell LMC"

  • #2
    Re: Setting Default Printer using a VBS script through a GPO

    I would use the below as a logon script:

    Code:
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    
    Set colInstalledPrinters =  objWMIService.ExecQuery _
        ("Select * from Win32_Printer Where Name = 'YOURPRINTER'")
    
    For Each objPrinter in colInstalledPrinters
        objPrinter.SetDefaultPrinter()
    Next
    MCSA 2000/2003

    Comment


    • #3
      Re: Setting Default Printer using a VBS script through a GPO

      thanks....we gave it a test run and received an error at Line 18 Char1

      thanks

      Comment


      • #4
        Re: Setting Default Printer using a VBS script through a GPO

        There is no line 18 (only 10 lines), have you modified the visual basic script?
        MCSA 2000/2003

        Comment


        • #5
          Re: Setting Default Printer using a VBS script through a GPO

          mbafmax use Notepad2.exe to edit the script.
          http://www.flos-freeware.ch/notepad2.html
          then copy-paste the line that errored

          Set the default printer always afterwards, after! you have connect all the printers
          Run the script as a User Logon script. Be sure the script is on a for the user accessable network share.

          \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


          • #6
            Re: Setting Default Printer using a VBS script through a GPO

            back to the script... sorry it was Line 8 Char 1 (For)

            thanks.........m

            Comment


            • #7
              Re: Setting Default Printer using a VBS script through a GPO

              Your first script will do fine:

              Code:
              strUNCPrinter = "\\sscsbackup\Dell LMC"
              Set objNetwork = CreateObject("WScript.Network") 
              objNetwork.AddWindowsPrinterConnection strUNCPrinter
              objNetwork.SetDefaultPrinter strUNCPrinter
              • Run the script as a User Logon script.
              • Be sure the script is on a for the user accessable network share.
              • Set the default printer always afterwards, after! you have connect all the printers


              \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


              • #8
                Re: Setting Default Printer using a VBS script through a GPO

                thanks... i have to ask,, how do i make sure it runs after the printer are connected?

                Yes.........Run the script as a User Logon script.
                Yes...........Be sure the script is on a for the user accessable network share.
                ??............Set the default printer always afterwards, after! you have connect all the printers


                Thanks so much.........

                Comment


                • #9
                  Re: Setting Default Printer using a VBS script through a GPO

                  Line 3 is connecting the printer, but there might be other scripts that run at logon that possibly adds printers after this part?

                  See how this logon script runs,
                  and check if the GPO is applied to the users in the OU.


                  \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


                  • #10
                    Re: Setting Default Printer using a VBS script through a GPO

                    thanks.........tons..........I will test it................m

                    Comment


                    • #11
                      Re: Setting Default Printer using a VBS script through a GPO

                      If you had search the forum then you already found the answer.
                      There are multiple topics about this.
                      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


                      • #12
                        Re: Setting Default Printer using a VBS script through a GPO

                        FYI... I did a search and did not have any luck....thanks........m

                        I'll try again with these key words..

                        Setting Default Printer using a VBS script through a GPO

                        Comment


                        • #13
                          Re: Setting Default Printer using a VBS script through a GPO

                          Try also "Search in Petri.co.il" with Google:
                          http://www.google.com/custom?hl=nl&c...ch=Petri.co.il

                          \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


                          • #14
                            Re: Setting Default Printer using a VBS script through a GPO

                            you need to search correctly
                            Search string: default printer
                            http://forums.petri.com/search.php?searchid=1175303
                            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

                            Working...
                            X