XP Batch file needed for mapping

  • Thread starter Thread starter Richard A
  • Start date Start date
R

Richard A

I need some help. I am the administrator on 200 XP pro
machines. Users do not have admin rights. Over the next
weekend, all of these users are moving from one office to
another and will also be connected to another print
server with new printer names. When I connect all of
these users over the weekend, and log on as the
administrator, is there any way I can map a network
printer for the user, or can I only do it for the
administrator.
If I had a wish, I would like to put a batch file on the
server that they all have access too. That batch file
when the user clicks it would map their new printer, and
delete all old printers in their profile.
Is there any way to do either one of these time saving
ideas. The thought of going to each desk on Monday to
map new printers is keeping me awake.
..
 
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
 
Not sure I understand your note... what part of this maps
the printer?
Is there a link I can read up on this and what all this
means...
-----Original Message-----
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
in message news:[email protected]...
 
When I use the command is it
WshNetwork.AddWindowsPrinterConnection "\\servername\HP
Laser Jet 6L"
and will that put the printer in all users profiles?
I will look at your links.. but I need to know what your
commands need. I have never used wshnetwork
-----Original Message-----
The lines with PRINTER in it.

http://www.google.com.au/search? q=AddWindowsPrinterConnection+&ie=UTF-
8&hl=en&btnG=Google+Search&meta=lr%3Dlang_en%7Clang_es-
http://home.comcast.net/~wizardofwhimsy/index.html
"Richard A" <[email protected]> wrote
in message news:[email protected]...
 
This is a Windows Script that uses WMI.
You can implement such scripts by implementing a Group
Policy object on your Windows Domain and setting it as a
logon script.
NOTE: You can also connect mapped drives and printers
using the NET USE command in a CMD script. CMD scripts
are simpler and not as robust as WSH.

You should save this text as a .WSH file as it is a
Windows Script file.
If you want some information on WMI check the web
for "Windows Management Instrumentation" or use the helper
tool in the Resource Kit.

-----Original Message-----
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
in message news:[email protected]...
 
You set it as a domain logon script for very stupid users who can't do the same thing on the Start menu. (this was written for one user)

Install Printer on print server, share it, put its share name in the two printer commands, one adds it to the list of printers, and one sets it as the default printer. Any errors will be in the event log.
 

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

Back
Top