'========================================================================== ' 'VBScript: AUTHOR: Ed Wilson , msft, 6/21/2006 ' 'NAME: 'ver 2.0 'COMMENT: Key concepts are listed below: '1.This script uses the new IADsTSUserEx interface from Windows 2003 to '2.Set properties on the ts profile of the user. '========================================================================== Option Explicit 'On Error Resume Next Dim strProvider 'Defines how will talk. Dim strOU 'Path to where object is located Dim strDomain 'Name of domain connecting to Dim strOUName 'User name Dim objUser 'Holds connection to ADSI strProvider = "LDAP://" strOU = "ou=mred," strDomain = "dc=nwtraders,dc=msft" strOUName = "cn=myNewUser," Const blnENABLED = 1 '1 enabled, 0 disabled Const blnBROKEN_CONNECTION = 1 '1 end session, 0 disconnect Const blnRECONNECTION = 1 '1 original client, 0 any client Const intREMOTE_CONTROL = 1 '0 disable, 1 enable input notify, 2 enable input NO notify '3 enable NO input notify, 4 enable NO input NO notify Const intMAX_CONNECTION =60 'Time in minutes Const intMAX_DISCONNECT =60 'Time in minutes Const intMAX_IDLE =10 'Time in minutes Const strHOME_DIR = "\\London\Shared\" 'UNC to home dir share. Uses username from funfix Const strHOME_DRIVE = "t:" 'Drive letter to use when mapping homedrive Const strPROFILE_PATH = "\\London\Profiles\" 'UNC to profile storage location. Uses username from funfix Const strINIT_PROG = "notepad.exe" 'Ensure in path, or provide FULL path to exe Const strWORK_DIR = "\\London\Profiles\" 'Folder to use for temp storage location. Combines with strTEMP_DIR Const strTEMP_DIR = "\tmp" 'Used with strWORK_DIR to set the temp storage location Set objUser = GetObject(strProvider & strOUName & strOU & strDomain) 'Terminal Services Profile tab objUser.AllowLogon = blnENABLED objUser.TerminalServicesHomeDirectory = strHOME_DIR & funfix(strOUName) objUser.TerminalServicesHomeDrive = strHOME_DRIVE objUser.TerminalServicesProfilePath = strPROFILE_PATH & funfix(strOUname) 'Remote control tab This property sets ALL 4 controls on the tab objUser.EnableRemoteControl = intREMOTE_CONTROL 'Sessions tab objUser.BrokenConnectionAction = blnBROKEN_CONNECTION objUser.MaxConnectionTime = intMAX_CONNECTION objUser.MaxDisconnectionTime = intMAX_DISCONNECT objUser.MaxIdleTime = intMAX_IDLE objUser.ReconnectionAction = blnRECONNECTION 'Environment tab objUser.ConnectClientDrivesAtLogon = blnENABLED objUser.ConnectClientPrintersAtLogon = blnENABLED objUser.DefaultToMainPrinter = blnENABLED objUser.TerminalServicesInitialProgram = strINIT_PROG objUser.TerminalServicesWorkDirectory = strWORK_DIR & funfix(strOUname) & strTEMP_DIR objUser.SetInfo subError '***************** Subs and Functions are below ************** Sub subError If Err.Number = 0 Then WScript.Echo("User " & funFix(strOUName) & " was modified") Else WScript.echo "An error occurred. It was: " & Err.Number End If End Sub 'Funfix function allows to use same variable for GetObject and properties Function funfix (strin) funFix = Mid(strin,4) 'Removes cn= from strOUName to give username funfix = Mid(funFix,1,Len(funFix)-1) 'Removes "," from end of strOUName End Function