Batch file to add a network printer

G

Guest

Hi
I want to create a batch file that, when it is run from a workstation, automatically connects to a network printer. If someone could let me know what the syntax for this would be I would really appreciate it. Thankyou

Regards
Lee
 
C

Carrie Garth

Lee said:
wrote in message I want to create a batch file that, when it is run from a workstation,
automatically connects to a network printer. If someone could let me know what the
syntax for this would be I would really appreciate it. Thankyou.

You might be able to find a suitable script from the samples at the following site:

Microsoft TechNet Script Center - Printing
http://www.microsoft.com/technet/community/scriptcenter/printing/default.mspx

And if you do not, or need any help with batch files, you may want to try posting
in the following Microsoft Newsgroup:

microsoft.public.win2000.cmdprompt.admin

Your newsgroup message header seems to indicate that you are posting to the Microsoft
Public Newsgroups using the Microsoft Communities Web Page. If I am correct, if you
click the first link below it will open your browser to:

Microsoft Communities Newsgroups Web Interface:
microsoft.public.win2000.cmdprompt.admin
http://communities2.microsoft.com/c...min&cat=en-us-servers-winserver&lang=en&cr=US

If you read newsgroups using a NNTP newsreader, such as Outlook Express, and
use the msnews.microsoft.com news server, here is a link:
news://msnews.microsoft.com/microsoft.public.win2000.cmdprompt.admin
 
D

David Candy

On Error Resume Next
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
strDriveHarasty = "Z:"
strDriveMorestaff = "Y:"

WshNetwork.MapNetworkDrive strDriveHarasty, "\\Server5\Share"
ReportErrors "Mapping Drive."
WshNetwork.MapNetworkDrive strDriveMorestaff, "\\Server5\Share"
ReportErrors "Mapping Drive."

WshNetwork.AddWindowsPrinterConnection "\\davidcan\HP Laser Jet 6L"
ReportErrors "Adding Printer."
WshNetwork.SetDefaultPrinter "\\h8\HP Laser Jet 6L"
ReportErrors "Setting Default Printer."
Sub ReportErrors(ErrText)
If err.number <> 0 then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.LogEvent 1, ErrText & " Error code " & err.number & " (" & err.description & ")"
Err.clear
End If
End Sub
 

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