Obviously, before you can share any printers, you need to set them up on the machine you want to share them from. Granted, you could print to network printers directly using a tcp/ip port on the local printer, but often you'll have you're printer server do that, and you'll share the printers through the server. Keeps your management nicely centralised, and allows the server to manage all printer queues.
Setting up local printers, or connecting to network printers via TCP/IP Ports, and how to script and batch process all that, was described in the previous pages.
Sharing printers on a Windows 2003 Server or Windows XP machine can be scripted easily using this script from Scripting Guy : Share All the Local Printers on a Computer.
strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer Where Network = FALSE") i = 1 For Each objPrinter in colInstalledPrinters objPrinter.Shared = TRUE objPrinter.ShareName = "Printer" & i objPrinter.Put_ i = i + 1 Next
The 'Shared' property, is a new addition to the Win32_Printer class in Windows 2003 / XP. This property does not appear in the version of WMI found in Windows NT or Windows 2000, which explains why this script will not work on those platforms.
Alternatively, the prncnfg.vbs script can serve as a command to configure printers on Windows 2003 Server or XP systems. Wit the -h switch, you can set sharing on and specify a sharename. This too requires the WMI version found on Windows 2003 Server or XP.
That means that sharing printers programmatically on, say a Windows 2000 Server, would be impossible (the NET SHARE command doesn't do the trick, definitly not for printers connected through tcp/ip ports). However, when setting up local printers with rundll32 printui.dll, you can use the /z and /Z switches to turn sharing of the printer on and of. An 8 character sharename will be generated automatically. Please refer to scripts for setting up local printers for a more elaborated discussion of printui.dll.
and take it frome there ...