Link to home
Start Free TrialLog in
Avatar of ldownward
ldownward

asked on

Login scripts

Can  any of you point me in the right direction of how to use Login scripts for Windows 2000 to map/add printers with out user intervention.

Thanks
Liam
Avatar of caronas
caronas

Think you mean a Windows2000-Server Domain:

The main script directory is in SYSVOL\Scripts (whereever you made your SYSVOL-directory)

Make a script like "netlogon.bat". If you only use W2K, NT and XP you can choose a "netlogon.cmd" as well, (W95,W98 need the "BAT" extension)

For example:
---cut--(NT-based only!)---
rem *** Bind drive
net use F: \\MYSERVER\MYOPENDIRECTORY /PERSISTENT:NO /Y
rem *** Bind printer
net use LPT1: \\MYSERVER\MYPRINTER /PERSISTENT:NO /Y
rem *** Use Servers TIME
net time /SETSNTP:myserver.mydomain.local
rem *** Message to Administrator that user has logged on
net send ADMINISTRATOR "%USERNAME% has logged on %DATE% !"
---cut---

Then you have to add that login-script to your user as Login-Script. Only put the loginscriptname into the field "login script" in profile-section.

You can add a home-directory there too (perhaps as drive)
For that directory you only need to write "NET USE H: /HOME" for example, because /HOME is interpreted as that entry.

You also can do that for whole organisations  within the grouprightlines (sorry i only know the german description)
Its a bit tricky ;-)

Greetings, Caronas
Avatar of ldownward

ASKER

Thanks for the reply Caronas,

What i am realy looking for is a solution where the login script will install a network printer. I allready tried the net use LPT1 command to no avail it did not work.

Thanks

Liam
Thanks for the reply Caronas,

What i am realy looking for is a solution where the login script will install a network printer. I allready tried the net use LPT1 command to no avail it did not work.

Thanks

Liam
Avatar of Steve Knight
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
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What is the errormessage when connecting to print-service ?

Have you tried it by hand (in "CMD"). All the commands will function without loginscript too!

Start->Execute->"CMD"->OK
[A CommandLineInterface will popup]

net use lpt2: \\Server\Printer

A little remark: These LPT(****) is only needed by dos-programs.

You should install the printer at the workstation itself if you want windows-printing (e.g. you use the netmeeting remote desktop, or with XP you also can use any terminal-client.)
(or expand your script with: "START \\Server\Printer", but that will drop unwanted printer windows on screen after the printer has been installed.)

perhaps there is another way through that group policies, but I had yet not the time to study that complex utility.
You can start a VB-Script from Loginscripts too if you want to do that thing very complex ;-)))
There are some VBScripts on the MS site, e.g. this one:

http://support.microsoft.com/default.aspx?scid=KB;en-us;q263226

which will add printers but you may be better off with START \\server\printer for simplicity - with a flag file set like I did above it will only appear once per desktop.

Since W2K and with W2K only clients we have taken to users choosing their own printers by selecting from http://server/printers (set as a standard link in their browser) sending them links to \\server\printer in email or showing them how to search AD for printers using Start | Settings | Printers and/or the Find Printer button in the File | Print Dialog boxes of Office etc.

Steve

Thanks Dragon-it, i had completly forgot about the start command. Thanks i can go home now and not loose any sleep :P.

Cheers
Liam
well here is my finished product for the printer logon script in whihc it uses a reference file ( a text file ), so the users will not keep getting the logon script to install the printers every time they logon on to the network:

@echo off
net time \\MY_SERVER /set /yes

if exist e:\printer_install\%username%\printer_install.txt goto end
if not exist e:\printer_install\%username%\printer_install.txt goto install

:install
e:
md printer_install
cd printer_install
md %username%
c:
net send %username% "PLEASE CLICK YES ON THE NEXT FEW SCREENS THAT POP UP FOR THE PRINTERS TO INSTALL"
START \\MY_SERVER\MY_PRINTER1
START \\MY_SERVER\MY_PRINTER2
START \\MY_SERVER\MY_PRINTER3
START \\MY_SERVER\MY_PRINTER3
COPY \\MY_SERVER\user_profiles\printer_install.txt E:\printer_install\%USERNAME%
net send %username% "YOUR PRINTERS HAVE BEEN SUCCESSFULLY INSTALED ON YOUR COMPUTER DATED %DATE%"
GOTO END

:end
exit


again guys thank you very much. I never found this site untill today. And yes i will be using this tech site often in the near future.


CHEERS :D
Liam
hmm You can always use vbscript and windows scripting host...as dragon-it said..

There's an object called wscript.network which allows you to install 2 kinds of printers..DOS printers(LPT1)... and windows printers...the DOS printer funciton doesn't work very well for me.... but the windows one is great...

i know it's abit late to post a comment now.. but maybe it can be of some help... it's quite simple to use vbscript and wsh... look for the chms in the microsoft knowledge base.... you just need to create a file with a .vbs extension... code it ..and add it to your scripts.....

windows 2000 already has WSH v3 ... and the printer functions are availabel in that vresion... if you want to delete printers you'll need the WSH 5.6 update.

this is a roughly what the code should look like...



set wshnetwork = createobject("wscript.network")
wshnetwork.addwindowsprinterconnection "\\server\printer"





You can add some code to map different printers for different users....

NOTE: this code doesn't work very well with win9x since you have to specify the driver name and spool32 doesn't like it alot...





Folks,

I am using Windows Login script to Map I Drive
SET PATH I: \\Server\USERS\%USERNAME% so that each user have folder on I driver when logon to system using logon name. My question is this. Is it possible to assign permission via Logon script so that only owner of folder can access it. Other users can't access someone else's folder on I drive other than his/her own folder. I can manually assign permission. But I wanna assign it via logon script.

Thanks

Tom
Short answer is no as to assign NTFS permissions you first need permissions and the login script runs as the user.  As an administrator just use the cacls and xcacls commands with a command line, choose your rights and write a batch file --> you can get a list of all directories with a dir /b > whatever.txt command then use a text editor or word to search & replace each line to include the bits needed for the cacls or xcacls command, call the file whatever.cmd and run it...