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
--
----------------------------------------------------------
http://www.g2mil.com/Dec2003.htm
"Lee" <anonymous.DeleteThis@discussions.microsoft.com> wrote in message news:A3918E70-C3C0-4931-96E0-B318605A0FD3@microsoft.com...
> 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