Solved

Terminal Services profile path script annoyance

Posted on 2006-07-23
2
511 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

831 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