rimmena
asked on
Script or utility to unshare a printer
I have recently installed Adobe Standard Writer 9.0 and as part of the installation it installs the printer driver and then shares it out.
I want the driver but I don't want it shared. Is there either a VBscript or utility that will remove the share ?
I need to deploy to multiple PC's so doing this manually is a no go.
I want the driver but I don't want it shared. Is there either a VBscript or utility that will remove the share ?
I need to deploy to multiple PC's so doing this manually is a no go.
ASKER
Does not remove it. I'll have a look at that link you mentioned.
Do you change Printer_Name for the name of your printer at line If objPrinter.name="Printer_N ame" Then?
ASKER
Yes.
Try running:
strComputer = "."
strprinter = ""
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
Wscript.Echo objPrinter.Name
Next
To be sure that it can "read" the names of the printers and find the exact name of the printer you are searching.
strComputer = "."
strprinter = ""
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
Wscript.Echo objPrinter.Name
Next
To be sure that it can "read" the names of the printers and find the exact name of the printer you are searching.
ASKER
This is weird, I can read the name with no issues, but the other script will not remove the sharing. Tried stopping and starting the print spooler as well
There was an error in the script
strComputer = "."
strprinter = ""
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
If objPrinter.name="Printer_N ame" Then
objPrinter.Shared=False
End If
Next
Try this please, the other says "obPrinter.Shared=False"
strComputer = "."
strprinter = ""
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
If objPrinter.name="Printer_N
objPrinter.Shared=False
End If
Next
Try this please, the other says "obPrinter.Shared=False"
ASKER
I spotted that and corrected it. Still no go :-(
Damn it.
Okey, then I only know one way to do it. At the registry in Hkey_local_machine\system\ currentcon trolset\co ntrol\prin t\printers \ are a key for every printer installed on the computer. Inside there are the keys that configure the printer. You can compare the values with the printer shared and without it and if you find the difference we can make a script that modifys it.
Hope this helps.
Okey, then I only know one way to do it. At the registry in Hkey_local_machine\system\
Hope this helps.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent, that worked a treat. So does the .Put_ apply it or something ?
Yes, the changes you made to the object objPrinter were not apply until you make the Put.
Pleased to help you.
Pleased to help you.
Maybe something like that (i don't prove it):
strComputer = "."
strprinter = ""
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
If objPrinter.name="Printer_N
obPrinter.Shared=False
End If
Next
You can find examples of VBS with printers in http://gallery.technet.microsoft.com/ScriptCenter/en-us/site/search?f[0].Type=SearchText&f[0].V
Hope this helps.