+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
Windows Thread, printers and login scripts in Technical; PHP Code: on error resume next Dim         objNetwork ,  compName Set objNetwork      =      CreateObject ( "WScript.Network" ) compName     =     lCase ( left ( objNetwork . ...
  1. #16
    ChrisP's Avatar
    Join Date
    Apr 2007
    Location
    norfolk
    Posts
    150
    Thank Post
    4
    Thanked 8 Times in 8 Posts
    Rep Power
    17
    PHP Code:
    on error resume next
    Dim         objNetwork
    compName

    Set objNetwork     
    =     CreateObject("WScript.Network")
    compName    =    lCase(left(objNetwork.ComputerName,3))
    if 
    compName "lap" then compname lCase(left(objNetwork.ComputerName,7))


    Select Case compName

        
    Case "lib"
            
    nukePrinters
            objNetwork
    .AddWindowsPrinterConnection "\\printserver1\Library HP CP2020"
            
    objNetwork.SetDefaultPrinter "\\printserver1\Library HP CP2020"

        
    Case "sp-"
            
    objNetwork.AddWindowsPrinterConnection "\\printserver2\Kyocera TASKalfa 250ci"
            
    objNetwork.SetDefaultPrinter "\\printserver2\Kyocera TASKalfa 250ci"

        
    Case "lap-ent","lap_ent"
            
    nukePrinters
            objNetwork
    .AddWindowsPrinterConnection "\\daisy\e1"
            
    objNetwork.AddWindowsPrinterConnection "\\printserver1\e2-2600"
            
    objNetwork.AddWindowsPrinterConnection "\\printserver1\e3-cp2020"
            
    objNetwork.SetDefaultPrinter "\\printserver1\e3-CP2020"

        
    Case "lap-hum","lap_hum"
            
    nukePrinters

        
    Case "lap-mfl","lap_mfl"
            
    nukePrinters

    End Select


    function nukePrinters
    strComputer 
    "."

    Set WshNetwork WScript.CreateObject("WScript.Network")
    Set objWMIService GetObject("winmgmts:" _
    "{impersonationLevel=impersonate}!\\" strComputer "\root\cimv2")
    Set colInstalledPrinters objWMIService.ExecQuery("Select * from Win32_Printer")
    For 
    Each objPrinter in colInstalledPrinters
    if InStr(objPrinter.Name"\\") > 0 then 
     WshNetwork
    .RemovePrinterConnection objPrinter.Name
    end 
    if 
    Next

    end 
    function 

  2. #17

    Join Date
    Nov 2005
    Location
    North
    Posts
    1,846
    Thank Post
    25
    Thanked 91 Times in 71 Posts
    Rep Power
    51
    Sort of related to this topic.

    Setting default printers is mentioned here.

    Just tried it on my 2003 domain and it works lovely... I just used a 2008 non DC server to do the preferences

    Set Default Printer with Windows 2008 Server Group Policy Preferences - Set the Default Printer via Group Policy | Windows Server Administration

  3. #18
    reggiep's Avatar
    Join Date
    Apr 2008
    Location
    In the vast area of space and time
    Posts
    1,550
    Thank Post
    518
    Thanked 56 Times in 50 Posts
    Rep Power
    30
    Quote Originally Posted by DaveP View Post
    This is a VBS script which runs at logon I use to remove:

    Microsoft Office Document Image Writer
    Microsoft XPS Document Writer
    Send To OneNote 2007

    The script:



    Hope this helps.
    I tried this and it works fine if I run it logged on as an admin, but if I call it to run during the logon scripts I get a premission denie error.
    Can anyone suggest how I can change the permissions to let the script run, it's pointing to line 8 of the script!

    Thanks

  4. #19
    reggiep's Avatar
    Join Date
    Apr 2008
    Location
    In the vast area of space and time
    Posts
    1,550
    Thank Post
    518
    Thanked 56 Times in 50 Posts
    Rep Power
    30
    Doh,
    I put it in to the boot script and it worked fine.
    Thanks

  5. #20

    Join Date
    Jul 2008
    Location
    Merseyside
    Posts
    299
    Thank Post
    17
    Thanked 10 Times in 10 Posts
    Rep Power
    14
    Use group policy?

  6. #21
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,529
    Thank Post
    108
    Thanked 89 Times in 75 Posts
    Blog Entries
    47
    Rep Power
    40
    an alternative

    rundll32 printui.dll,PrintUIEntry /in /n\\SERVERX\XMono

  7. #22

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    9,265
    Thank Post
    242
    Thanked 1,575 Times in 1,254 Posts
    Rep Power
    341
    I deploy printers per user, per computer or a combination of both using 2003 R2 Print Management.

    As for setting up the default printer I use a reg file at logon to set the default:

    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows]
    "Device"="\\\\SERVERNAME\\PRINTER-NAME,winspool,Ne03:"
    The easiest way is to set a printer as default, then navigate to HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows within the registry and export the entries, then save the reg file within your NETLOGON share and update logon scripts accordingly.

  8. #23


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,800
    Thank Post
    231
    Thanked 883 Times in 759 Posts
    Rep Power
    300
    recently ive started deploying with the 2003 r2 method and deploying printers to a policy then assigning that to the appropriate ou or using filtering and applying it to a group then adding a login script running pushprinterconnection to xp pcs. To set the default i use a heavily cut down version of my old vbs script that just sets the dfault printer (sets it once as network printer then tries to set it as local printer and all my local printers are called local printer)

    Code:
    ' Printers.vbs - Jonathan
    Option Explicit
    Dim objNetwork
    on error resume next
    
    Set objNetwork = CreateObject("WScript.Network") 
    objNetwork.SetDefaultPrinter "\\server\Laser1"
    objNetwork.SetDefaultPrinter "local printer"
    i just copy a shortcut to that vbs scrpit to %allusersprofile%\start menu\programs\startup\printers.lnk and as i always copy it with a name specified if i move it to a new ou it will copy say suite.lnk or ks1.lnk as printers overwriting the old one. On older deployments i just did the vbs
    objNetwork.SetDefaultPrinter "local printer"

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 23
    Last Post: 13th November 2013, 01:29 PM
  2. Printers disappearing after login script
    By gshaw in forum Windows
    Replies: 11
    Last Post: 10th June 2009, 06:47 PM
  3. login scripts
    By palmer_eldritch in forum Mac
    Replies: 1
    Last Post: 6th March 2008, 10:47 AM
  4. Replies: 7
    Last Post: 20th December 2007, 03:45 PM
  5. Problem with Home Drive and login scripts
    By ArchersIT in forum Windows
    Replies: 4
    Last Post: 11th July 2007, 12:17 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •