Any method to add printer programatically?

M

Mullin Yu

I want to know can I add printer programatically?

E.g. I want to create a File Printer to a specify local port, say,
C:\test\test.prn with the name as FilePrinter

Can I do so?

Thanks!

Regards,
Mullin
 
A

Adrian Mascarenhas

->
I want to know can I add printer programatically?

E.g. I want to create a File Printer to a specify local port, say,
C:\test\test.prn with the name as FilePrinter

You can do it using wscript and then call the script inside C#. See msdn link: http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/script56/html/wsmthsetdefaultprinter.asp

var WshNetwork = WScript.CreateObject("WScript.Network");
var PrinterPath = "\\\\research\\library1";
WshNetwork.AddWindowsPrinterConnection(PrinterPath);
WshNetwork.SetDefaultPrinter(PrinterPath);


--
Adrian Mascarenhas, Developer Division

This posting is provided "AS IS" with no warranties, and confers no rights.

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top