Following on from my previous post about KIX login scripts (KIX login script to map printers, network drives and setting changes), this article will show you how to make a login script for a Remote Desktop Services (RDS) Server/Terminal Server. I have tested this and this works on the latest Windows 2008 R2 RDS server fine.

When a user logs in, we want to find out whether they are logging into their computer/laptop or are they logging into the RDS/Terminal Server. After much searching around the internet on how can a login script distinguish between a normal desktop/laptop and a Terminal/RDS server, I found the easiest way is to create a Registry Key on the RDS/Terminal Server and do a IF statement which says: “Check if this registry key exists, if it does, then run the TerminalServer.kix file”.  Here is what the KIX line looks like (add it to the existing kix file from the original article above if you want):

;================================
; If user is on a Terminal Server,
; execute ** TerminalServer.kix ** instead
; Otherwise continue on with the rest of script
;================================

$TERMINALSERVER = ReadValue (HKEY_LOCAL_MACHINE\SYSTEM, “Terminal Server”)
 If $TERMINALSERVER = “1” Call @ScriptDir + “\TerminalServer.kix”
 EXIT
EndIf

Here is a details explanation of what that section above means and does:

  1. What I first did was in the Registry of the Terminal (RDS) server, I created a new [String Value] called “Terminal Server” under HKEY_LOCAL_MACHINE\SYSTEM and put in a value of “1“.
    (You can create the registry key anywhere you like or put in a value of anything you want. I just chose that Registry Key and value because it was simple. If you decide on something else, make sure you change it in the line above)


  2. This line:
    $TERMINALSERVER = ReadValue (HKEY_LOCAL_MACHINE\SYSTEM, “Terminal Server”)
    Reads the “Terminal Server” value from registry key HKEY_LOCAL_MACHINE\SYSTEM and defines what is there to be the variable $TERMINALSERVER

  3. This line:
    If $TERMINALSERVER = “1” Call @ScriptDir + “\TerminalServer.kix”
    Says if the $TERMINALSERVER variable is equal to 1, then call on the TerminalServer.kix file.
    So we have to create the Registry Key manually on the Terminal (RDS) server before hand. This is usually not too much of a problem but you you just have to document it in your Remote Desktop Services server build to always manually add in this key when building/rebuilding your RDS/Terminal Server. This is really the only way I can find that tells the script the user is logging into a Terminal server as we only want the script to run on a Terminal (RDS) server only and not on a desktop/laptop.

Now you can go and create a seperate TerminalServer.kix file which will only run if the user logs into a Remote Desktop Services/Terminal Services server. 

In the TerminalServer.kix file, I have a section that….continue on page 2 

GD Star Rating
loading...
GD Star Rating
loading...

Related Posts:

Pages: 1 2