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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
WindowsITAdminCommented:
Do you change Printer_Name for the name of your printer at line   If objPrinter.name="Printer_Name" Then?
0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.