Take a look at another post updated to include a Terminal Server environment here: KIX login script to map network drives, printers and applicaton settings for Remote Desktop Services (Terminal) Server – Revised

This is an example KIX login script that map printers, network drives and makes setting changes. The aim is to make life abit easier for us System Administrators for managing drive and printer mappings. New users will automatically get network drives and printers mapped for them when they login.

;=============================================
;Map Network Drives
;=============================================

If InGroup("_Drive_S_Drive")
Use S: "\\SERVER\Data"
EndIf

If InGroup("_Drive_P_Drive")
Use P: "\\SERVER\Public"
EndIf

;=============================================
;Map Printers
;=============================================

If InGroup("_Printer_HP_M1522NF")
ADDPRINTERCONNECTION ("\\SERVER\HP Laserjet M1522NF")
EndIf

If InGroup("_Printer_HP_P2014N")
SHELL 'con2prt /cd "\\SERVER\HP Laserjet P2014N"'
EndIf

;=============================================
;Application specific settings
;=============================================

If InGroup("Domain Users")
del "%USERPROFILE%\Start Menu\Programs\Outlook Express.lnk" /F /Q
EndIf

;=============================================
; Aphelion Shortcuts
;=============================================

If InGroup("_App_Aphelion")
SHELL 'robocopy "\\SERVER\NETLOGON\Files\Aphelion V4" "%USERPROFILE%\Desktop\Aphelion V4" /COPY:DAT /MIR /R:0 /W:0'
EndIf

 

Here is a detailed explanation of what the lines in the script means and does:

  1. This means it will map the S:\drive if the user is part of the “_Drive_S_Drive” security group in Active Directory. This is helpful if you are wanting to map a network drive based on a user’s security group membership. Therefore, if they are not part of that group, that drive doesn’t get mapped for them. If they try to map it manually, it won’t let them because you would have put security on that share.
    If InGroup("_Drive_S_Drive")
    Use S: "\\SERVER\Data"
    EndIf

  2. This means it will map the printer (HP Laserjet M1522NF) if the user is part of the “_Printer_HP_M1522NF” security group in Active Directory. This is helpful if you are wanting to map a printer based on a user’s security group membership. Therefore, if they are not part of that group, that printer doesn’t get mapped for them. If they try to map it manually, it won’t let them because they won’t have the permissions to. You can also change the group to be “Domain Users” instead. Then add all printer shares to it. What that then means is everyone will automatically get all the printers in their organisation mapped for them during login.
    If InGroup("_Printer_HP_M1522NF")
    ADDPRINTERCONNECTION ("\\SERVER\HP Laserjet M1522NF")
    EndIf

  3. This means it will set the HP Laserjet P2014N printer as the users default printer if the user is part of the “_Printer_HP_P2014N” security group in Active Directory. This calls on the con2prt executable to connect to that printer and set it as the users default printer. More information about the con2prt tool can be found here – con2prt.exe – Map, delete, and set default printer. This is helpful if you want to automatically set a user’s default printer for them. It works well if you create this for all your printers and add users to their appropriate group. Then, if the user moves to a different location in the building and needs a different printer as their default, just add them to the other printer group.
    If InGroup("_Printer_HP_P2014N")
    SHELL 'con2prt /cd "\\SERVER\HP Laserjet P2014N"'
    EndIf

  4. This simply removes the Outlook Express shortcut from the user’s Start Menu as in an organisation, no one uses it when they already have Outlook installed.
    If InGroup("Domain Users")
    del "%USERPROFILE%\Start Menu\Programs\Outlook Express.lnk" /F /Q
    EndIf

  5. This uses the Robocopy program to copy a folder of shortcuts that is on the server’s NETLOGON share onto the user’s desktop during login. If they are part of the “_App_Aphelion” security group, then a folder of shortcuts relating to the Aphelion program gets copied to the users Desktop. Robocopy is very fast and will automatically skip the files/folders if they are of the same size and timestamp. So if the user doesn’t change it, it won’t do anything. However, if the user decides to rename the shortcut or delete it, next time they log in, it will wipe out those changes and copy over a fresh set of shortcuts again regardless.
    If InGroup("_App_Aphelion")
    SHELL 'robocopy "\\SERVER\NETLOGON\Files\Aphelion V4" "%USERPROFILE%\Desktop\Aphelion V4" /COPY:DAT /MIR /R:0 /W:0'
    EndIf

 

So, now that you have an understanding of what the kix file does;

HOW do you implement this script to a user’s login?

The easiest way is in your normal login script, call on the kix file. The example kix file mentioned on page 1, I save as connect.kix.

What I then do is create a login.bat batch file (or you can modify your existing login batch file) and in that file, include this one line:

%0\..\kix32 %0\..\connect.kix

The line above just calls on the KIX32.exe program (which also needs to be installed on the same location as the login.bat file, generally on the server’s NETLOGON share) to run the connect.kix file.

You can download the complete package which has the sample kix file mentioned in this article, along with all the necessary executable programs from here – Sample Login Script with kix32.exe, con2prt.exe and robocopy.exe.

UPDATE 2: Take a look at another post updated to include a Terminal Server environment here: KIX login script to map network drives, printers and applicaton settings for Remote Desktop Services (Terminal) Server – Revised

UPDATE 1: I have updated this post to include a KIX login script which you can use for a Remote Desktop Services (Terminal Services) server here: KIX login script for Remote Desktop Services Server (Terminal Server)

GD Star Rating
loading...
GD Star Rating
loading...
KIX login script to map printers, network drives and setting changes, 4.0 out of 5 based on 2 ratings

Related Posts: