Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic Connection to Printers

Status
Not open for further replies.

KRB548

Technical User
Feb 4, 2003
10
GB
I have serveral printers located around a school. I want to be able to automatically connect users to printers that are located near to where they are logging on then when they log off disconnect the printers. Then when they go to a different room agin connect to the printers closest to that room.

I have Win2K server and the users are using either a mandatory or roaming profile.

Does anyone have any scripts they can share with me to be able to do this?
 
KRB548

There is a way under win2k to assign and delete printers in the way you want using the net use command. I have included a link to the net use page on the Microsoft website. Very, very useful command because it controls network resources from batch files or login scripts.

I'll leave it to you to decide how you get these scripts to run. If they already have login scripts then use those. They can contain conditionals such as if..then..else, which I would advise using.

The weblink is below


If you are using DOS batch files, then I highly recommend (and I've not tried it yet myself) looking at KixStart which is a newer scripting tool available I believe on the Win2k Resource Kit.

It allows for better scripts to be created with if member of Group then. Such that you can program, a single script with elequent decisions taking place in it. Far more network oriented than DOS. Both are suitable for what you want to do though.

Good Luck

Hargy
 
I found this complex and yet useful script on another forum

Thanks to dragon-it on Experts Exchange for that one

If you are using just W2K clients then you can also add login scripts through Group Policy for all users under a particular OU in Active Directory (or you can specify which users by applying a group too).

You right click on an OU in Active Directory Users & Computers, select Properties, and Add a new Group Policy. Have a look down the options and you'll find Scripts entries for Logon and Logoff that can be run by Users and for PC's at Startup and Shutdown (before user logs in).

If you don't have just W2K clients you'll have to stick with the old way for now.

The following extract of a login script shows you the use of the ifmember.exe command which you can use to set different drive mappings etc. depending upon which groups a person is in. This command comes with the NT/W2K Resource Kit and you can use that with either a Group Policy or normal login script.

It also has some error checking so that the script stops at the end if an error occurs in mapping one of the drives.

Steve

@echo off
SET LS_Error=

Echo *** Turn off persistent mappings for NT / 2000 ***
net use /persistent:no

Echo *** Set time from server ***
net time \\PDC_NAME /set /yes
if errorlevel 1 set LS_Error=SET TIME

ifmember "DOMAIN\Map_System Root to G"
if not errorlevel 1 goto SkipG
echo *** Map Root drive ***
net use g: \\FILESERVER\Root
if errorlevel 1 set LS_Error=%LS_Error% G (ROOT)
:SkipG

Echo *** Map Apps drives ***
net use h: \\FILESERVER\Applications
if errorlevel 1 set LS_Error=%LS_Error% H (APPS)

echo *** Logging PC usage ***
\\FILESERVER\policies\LoginAudit.exe

REM rather than using Home drive in user property
REM this sets a home drive just by username

Echo *** Map Home drives ***
if "%username%"=="" set LS_NoName=TRUE
if "%username%"=="" goto skipI
net use i: \\FILESERVER\users\%username%
if errorlevel 1 set LS_Error=%LS_Error% I (HOME)
:skipI

Echo *** Map Shared drive ***
net use K: \\FILESERVER\Shared
if errorlevel 1 set LS_Error=%LS_Error% K (SHARED)

if not exist i:\notes\desktop5.dsk goto skipnotes
Echo *** Copying Notes Desktop5.DSK to hard drive ***
copy i:\notes\desktop5.dsk c:\notes\data
:skipnotes

echo *** Configure Screen Saver ***
regedit -s \\fileserver\policies\screensaver.reg

goto checkerror

:checkerror
if "%LS_Error%"=="" goto end
echo.
echo ****************
echo * Login Script *
echo ****************
echo.
echo User: %USERNAME%
echo.
echo There has been a problem mapping drives to the servers.
echo.
echo Please place a helpdesk call or contact I.T. support stating the error below:
echo.
echo.
if "%LS_NoName%"=="True" echo Unable to map home drives as username is not set
echo Error with %LS_Error%
echo.
pause
 
Sorry mate

The command to do this is

net use LPT1: \\MYSERVER\MYPRINTER /PERSISTENT:NO /Y

Hargy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top