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.
LVL 6
rimmenaAsked:
Who is Participating?
 
WindowsITAdminCommented:
I FIND THE SOLUTION, IT WORKS ON MY COMPUTER, TRY THIS 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_Name" Then
           objPrinter.Shared=False
           objPrinter.Put_
    End If
Next

Hope this helps.
0
 
WindowsITAdminCommented:
Hi.

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_Name" Then
           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].Value=printers&pageIndex=1

Hope this helps.
0
 
rimmenaAuthor Commented:
Does not remove it. I'll have a look at that link you mentioned.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
WindowsITAdminCommented:
Do you change Printer_Name for the name of your printer at line   If objPrinter.name="Printer_Name" Then?
0
 
rimmenaAuthor Commented:
Yes.
0
 
WindowsITAdminCommented:
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.
0
 
rimmenaAuthor Commented:
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
0
 
WindowsITAdminCommented:
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_Name" Then
           objPrinter.Shared=False
    End If
Next

Try this please, the other says "obPrinter.Shared=False"
0
 
rimmenaAuthor Commented:
I spotted that and corrected it. Still no go :-(
0
 
WindowsITAdminCommented:
Damn it.

Okey, then I only know one way to do it. At the registry in Hkey_local_machine\system\currentcontrolset\control\print\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.
0
 
rimmenaAuthor Commented:
Excellent, that worked a treat. So does the .Put_ apply it or something ?
0
 
WindowsITAdminCommented:
Yes, the changes you made to the object objPrinter were not apply until you make the Put.

Pleased to help you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.