shornesr
asked on
Global Install of Printers using VBScript
I know there is a simple way to install a printer using VBScript.
However, it is only for the current user.
How can I use VBScript to install one for ALL USERS that sign on to a computer.
We are using Active Directory with Windows Server 2003.
However, it is only for the current user.
How can I use VBScript to install one for ALL USERS that sign on to a computer.
We are using Active Directory with Windows Server 2003.
ASKER
I replaced the SERVERNAME with our print server.
I replaced the "Printer01", "Printer02" etc with the printer share names.
This did not work. I got an error message saying "Unable to add the per machine printer connection. Operation could not be completed."
I got this error three times because I was trying to add three printers.
Did I do something incorrectly?
I replaced the "Printer01", "Printer02" etc with the printer share names.
This did not work. I got an error message saying "Unable to add the per machine printer connection. Operation could not be completed."
I got this error three times because I was trying to add three printers.
Did I do something incorrectly?
ASKER
I simply ran the VB Script from the desktop. Should it run as a start-up script?
Fix some typo issues. Try this one.
You can run it from the desktop like you did. There are many ways to deploy this once you are ready. One way would be to create a computer startup script GPO to run this. If that is how you want to do it, we should add some logic to check if the printer exists before trying to add it to avoid error messages.
You can run it from the desktop like you did. There are many ways to deploy this once you are ready. One way would be to create a computer startup script GPO to run this. If that is how you want to do it, we should add some logic to check if the printer exists before trying to add it to avoid error messages.
'Set Variables
strComputer = "."
strAddPrinter = "rundll32 printui.dll,PrintUIEntry /ga /c\\" & strComputer & " /n"
strDeletePrinter = "rundll32 printui.dll,PrintUIEntry /gd /c\\" & strComputer & " /n"
strDefaultPrinter = "rundll32 printui.dll,PrintUIEntry /y /c\\" & strComputer & " /n"
strPrintServer = "\\SERVERNAME\"
strQuote = Chr(34)
strStopService = "SC \\" & strComputer & " stop spooler"
strStartService = "SC \\" & strComputer & " start spooler"
Set objShell = CreateObject("WScript.Shell")
'Create array of printer numbers to be installed
arrPrinters = Array("Printer01", "Printer02", "Printer03", "Printer04")
'Create network printer per machine
For Each objPrinter In arrPrinters
objShell.Run strAddPrinter & strQuote & StrPrintServer & objPrinter & strQuote
WScript.Sleep(1000)
Next
'Give the computer time to complete process
WScript.Sleep(5000)
'Stop And Start print spooler service
objShell.Run strStopService
WScript.Sleep(10000)
objShell.Run strStartService
ASKER
Still getting the same error...
I am adding the name of the print server and the share names for the printers....
I am adding the name of the print server and the share names for the printers....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great!!! Thank you. It worked just right!
Just remember, if you want to delete these printers later , you must use the script with the strDeletePrinter. If you just delete from the printers list in windows, they will be recreated on the next reboot.
ASKER
Thank you...
Next I'll be figuring how to use it as a start-up script in Active Directory....
I really appreciate the help!
Next I'll be figuring how to use it as a start-up script in Active Directory....
I really appreciate the help!
rlandquist:
how can this script be modified to only install specific printers from print servers? Not all computer get all printers that are on print server.
how can this script be modified to only install specific printers from print servers? Not all computer get all printers that are on print server.
Nevermind I see it now
Open in new window