Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a requirement that through group policy all client computers needs to have a Printer installed called "PostScript Printer", every example I find online is for installing a network printer (which is not what I want).

Any help would be appreciated.

Thanks.

share|improve this question
    
A bit more info about that this printer is would be really useful –  Izzy Jul 16 '09 at 14:18
    
There is no printer. I'd just like to hijack some default drivers. –  Allain Lalonde Jul 16 '09 at 14:29

1 Answer 1

up vote 1 down vote accepted

Following code did the trick for me. Not perfect, but it works.

Option Explicit

'On Error Resume Next
Dim oWshShell, objWMIService

Set oWshShell = CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")  

Function PrinterExists(PrinterName)    
  Dim colPrinters, objPrinter

  Set colPrinters = objWMIService.ExecQuery _
      ("Select * From Win32_Printer Where DeviceID = '" & PrinterName & "'")  

  PrinterExists = False
      For Each objPrinter in colPrinters
      PrinterExists = True
  Next
End Function

Sub RenamePrinter(NameBefore, NameAfter)
  Dim colPrinters, objPrinter
  Set colPrinters = objWMIService.ExecQuery _
      ("Select * From Win32_Printer Where DeviceID = '" & NameBefore & "'")  

  For Each objPrinter in colPrinters
      objPrinter.RenamePrinter(NameAfter)
  Next
End Sub

Function InstallPrinter(PrinterName)
  If Not PrinterExists(PrinterName) Then
    Installing = oWshShell.Run("rundll32 printui.dll PrintUIEntry /if /f         %windir%\inf\ntprint.inf /r ""file:"" /m """ & PrinterName & """")
  End If


  Dim FailCount
  FailCount = 0

  Do While Not PrinterExists(PrinterName) And FailCount < 5
    WScript.Sleep 1000
    FailCount = FailCount + 1
  Loop

  InstallPrinter = PrinterExists(PrinterName)
End Function

Dim Installing

If Not PrinterExists("PostScript Printer") Then
  'XP makes this apple printer available
  If InstallPrinter("Apple Color LW 12/660 PS") Then
    RenamePrinter "Apple Color LW 12/660 PS", "PostScript Printer"
  Else
    'Don't know of a vista one yet
  End If
End If
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.