Page 1 of 1 1
Topic Options
#151929 - 2005-11-21 01:46 PM find out printer share names - solved
derkleinemuck Offline
Lurker

Registered: 2005-11-21
Posts: 3
Hi there,

I have a problem deleting some printers...
To delete a remote printer, I have to use DelPrinterConnection("Sharename"). But I don't know the sharename, only the printername. I couldn't find any sharename in the registry, so how can I find out the sharenames?
Background is that I have to switch some clients from one server to another. So a script should find out which printer is installed on the client.

Thanx in advance

Marcus


Edited by derkleinemuck (2005-11-22 10:35 AM)

Top
#151930 - 2005-11-21 02:12 PM Re: find out printer share names
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
If you browse to the printer server in network neighborhood you will see the printers there. These are the share names.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#151931 - 2005-11-21 02:40 PM Re: find out printer share names
derkleinemuck Offline
Lurker

Registered: 2005-11-21
Posts: 3
Yes, that's right, but how do I read this with a script?. It should be universal for diffrent servers. I don't want to hardcode the printernames in the skript. That's not very nice
Top
#151932 - 2005-11-21 03:09 PM Re: find out printer share names
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
You could enumerate the subkeys from this key (on the printer server).

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers

Then it depends on if your printernames and share names are the same.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#151933 - 2005-11-21 08:48 PM Re: find out printer share names
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Won't "Net View \\servername" give you what you need? It returns the share name of all shares, followed by the share type.

Code:
Shell '%COMSPEC% /c net view \\servername | find /i "PRINT" > printers.txt'


would create a file with the printer shares that you could then parse. Don't forget to delete the file when you're done.

This is a good way to get started. As you get some experience, WMI might be a good alternative to investigate.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#151934 - 2005-11-22 10:34 AM Re: find out printer share names
derkleinemuck Offline
Lurker

Registered: 2005-11-21
Posts: 3
Thanks for the answers.
I got a solution for the problem by using WMI. Here is the result

Code:
 
$Printers = GetObject("winmgmts:").ExecQuery("Select * from Win32_Printer where ShareName <> NULL")
For Each $Printer In $Printers
? $Printer.Name " - " $Printer.ShareName
Next


The select gets only printers with sharename not NULL because this are localy installed printers.

Greets
Marcus

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.114 seconds in which 0.087 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org