Welcome to MSFN

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


Sign in to follow this  
Followers 0
Dobby

How do you share a printer programatically?

6 posts in this topic

I've searched high and low (Google and MSFN Forum that is!) but can't find any command to share a printer without resorting to reg hacking (Not sure if even that can be done yet). NET SHARE seems to be the closest thing but for printers the only option is to delete shares and this doesn't even seem to work properly either (The share is still active according to Control Panel->Printers And Faxes).

Help would be appreciated.

Thanks.

0

Share this post


Link to post
Share on other sites

Here is a VBS script that is supposed to share all printers on the network

Here is the link to the article where I found this script.

Hey Script Guys Share Printer

'''' This is for XP/2003 only

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

0

Share this post


Link to post
Share on other sites

WOW! Thanks that was a quick response!! I started looking at printui.dll which might have worked if I installed the printers using this command instead of integrating them which is not ideal.

Just tried the script and it works fine. Just need to change the share names to something a little more meaningful.

Thanks very much.

0

Share this post


Link to post
Share on other sites

here try it this way

' these comment out the line in the script so they dont get read while the script is active.

'''' This is for XP/2003 only

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

'If 'objPrinter.ShareName = "Place The PrinterName Here"

'objPrinter.Put_

'exit for

'End If

i = i + 1

Next

0

Share this post


Link to post
Share on other sites

Actually the names do not need to be more meaningful as the Printer UI shows the full name of the printer anyway.

I'm adding the connection to my client machine like this but it seems to always prompt 'You are about to connect to a printer on a server' :

rundll32 printui.dll PrintUIEntry /in /n\\server\printer1

I've tried the options /q /Gw to try to suppress them but doesn't seem to make any difference.

I'll dig around further.

Edited by Dobby
0

Share this post


Link to post
Share on other sites

Seems like someone else had the same problem:

from http://www.msfn.org/board/index.php?s=&sho...ndpost&p=172024

Printer.vbs

Set WshShell = WScript.CreateObject ("WScript.Shell")
WshShell.Run ("rundll32 printui.dll,PrintUIEntry /in /n\\studeerkamer\samsung /q")
WScript.Sleep 5000
WshShell.SendKeys "{ENTER}"
WScript.Quit

Thanks again for your help.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.