Solved

Terminal Services profile path script annoyance

Posted on 2006-07-23
2
507 Views
Last Modified: 2011-09-20
Hi experts,

Trying to get a script to work, want to populate the Terminal Services profile path when users log into the network by calling a script from AD. It all seems to work on the server, but when I run it from the client machines I get an "object not supported" error when it tries to set the TS profile path. I suspect this is because the PCs, being XP, aren't TS aware, and don't know of the existence of this property of the user object? But that's just my guess.  The script is shown below:

(thanks very much for any help!)

'
' VBScript login script
' v1.1    12/07/06
' -----------------------------------------------------------------

Option Explicit
Dim objNetwork, objUser, objSysInfo
Dim strSharedDriveLetter, strSharedDrivePath, strUsername, strProfilePath
Dim strTermSvrProfilePath, strHomeDriveLetter, strHomeDrivePath, strUserPath, strUserCn

strSharedDriveLetter = "S:"
strSharedDrivePath = "\\iaserveresp\shared"
strHomeDriveLetter = "H:"
strHomeDrivePath = "\\iaserveresp\user\"
strProfilePath = "\\iaserveresp\profile\"
strTermSvrProfilePath = "\\iaserveresp\profile\termsvc\"

Set objNetwork = CreateObject("WScript.Network")
Set objSysInfo = CreateObject("ADSystemInfo")

strUserCn = objSysInfo.UserName
strUsername = objNetwork.Username
strUserPath = "LDAP://" & strUserCn
set objUser = GetObject(strUserPath)

' Now create user object to set TS & normal profile paths if theyre blank

if objUser.ProfilePath = "" Then ' if the user's profile path is blank
  objUser.ProfilePath = strProfilePath & strUserName ' set it to what it should be
  objUser.SetInfo
end if

if objUser.TerminalServicesProfilePath = "" Then ' if the user's TS profile path is blank
  objUser.TerminalServicesProfilePath = strTermSvrProfilePath & strUserName
  objUser.SetInfo
end if

' Time to map the various drives
On Error Resume Next ' If there's already an S: drive it'll throw an error
objNetwork.MapNetworkDrive strSharedDriveLetter, strSharedDrivePath ' heres where it maps the drive
If Err.Number <> 0 Then ' if there is an error mapping the drive
  On Error Resume Next
  objNetwork.RemoveNetworkDrive "S:", True, True  ' delete the existing mapping
  objNetwork.MapNetworkDrive "S:", strSharedDrivePath  ' and create a new one
End If

WScript.Quit

0
Comment
Question by:georgemason
2 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 125 total points
ID: 17164401
That doesn't work because you're running it as a logon script. The users (and the logon script is running in the user's context) don't have permissions to change their properties in AD.
You need to change the script so that it iterates through your AD, checks for users with empty roaming profile paths, and changes it to the appropriate location.
0
 
LVL 1

Author Comment

by:georgemason
ID: 17164529
Right. That's that idea then.

I'll schedule the script to run once a week and correct any empty profile paths. Thanks for posting.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Find out what the Office 365 disclaimer function is, why you would use it and its limited ability to create Office 365 signatures.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now