Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Terminal Services profile path script annoyance

Posted on 2006-07-23
2
Medium Priority
?
529 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 85

Accepted Solution

by:
oBdA earned 375 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
LinkedIn blogging is great for networking, building up an audience, and expanding your influence as well. However, if you want to achieve these results, you need to work really hard to make your post worth liking and sharing. Here are 4 tips that ca…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

810 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