keybrdcowboy
IS-IT--Management
I keep getting a "object doesn't support this property" error. I know what the error means, but I don't know why I keep getting it, or better yet, what I need to do to fix it. Can anyone help? The error is for the line that says to get the user's home drive and change it...
Here's the code:
Option Explicit
Dim newDirectory, fsoIn, inFile, fsoOut, outFile, arruserPath, strDirPath, strUserName
Dim objUser, strHomeDrive, strHomeDirPath, strTest
Const inFilename = "usernames.txt"
Const outFilename = "ChangeHomeDirPath.log"
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
' Open the input file
Set fsoIn = CreateObject("scripting.filesystemobject")
Set inFile = fsoIn.OpenTextFile(inFilename, ForReading, True)
' Open the log file (append mode) and timestamp the entry
Set fsoOut = CreateObject("scripting.filesystemobject")
Set outFile = fsoOut.OpenTextFile(outFilename, ForAppending, True)
outFile.writeline (Now & vbTab & "Starting script...")
While Not inFile.AtEndOfStream
arrUserPath = Split(inFile.Readline, vbTab, -1, 1)
' arrUserPath(0) contains the user names
strUserName = arrUserPath(0)
strHomeDrive = "Z:"
strHomeDirPath = "\\server\" & strUserName
' Connect to the user account in AD
Set objUser = GetObject("WinNT://" & strUserName & "user")
'strTest = objUser.homedirectory
'wscript.echo strtest
If Err.Number <> 0 Then
outFile.writeline Now & vbTab & "Error connecting to " & strUserName & " --- " & Err.Description
Err.Clear
ErrorOccurred = True
Else
' Set the path for the account
On Error Resume Next
objUser.put "HomeDrive", "Z:"
On Error Goto 0
objUser.HomeDirectory = strHomeDirPath
objUser.SetInfo
If Err.Number <> 0 Then
outFile.writeline Now & vbTab & "Error setting home directory path for " & strUserName & " --- " & Err.Description
Err.Clear
ErrorOccurred = True
Else
outFile.writeline (Now & vbTab & "Home directory set for " & strUserName)
End If
End If
Wend
' Clean up the environment
outFile.writeline (Now & vbTab & "Ending script...")
inFile.close
outFile.close
If ErrorOccurred Then
msgbox "Script completed with errors. Please check the log file."
Else
MsgBox "Script completed successfully."
End If
Here's the code:
Option Explicit
Dim newDirectory, fsoIn, inFile, fsoOut, outFile, arruserPath, strDirPath, strUserName
Dim objUser, strHomeDrive, strHomeDirPath, strTest
Const inFilename = "usernames.txt"
Const outFilename = "ChangeHomeDirPath.log"
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
' Open the input file
Set fsoIn = CreateObject("scripting.filesystemobject")
Set inFile = fsoIn.OpenTextFile(inFilename, ForReading, True)
' Open the log file (append mode) and timestamp the entry
Set fsoOut = CreateObject("scripting.filesystemobject")
Set outFile = fsoOut.OpenTextFile(outFilename, ForAppending, True)
outFile.writeline (Now & vbTab & "Starting script...")
While Not inFile.AtEndOfStream
arrUserPath = Split(inFile.Readline, vbTab, -1, 1)
' arrUserPath(0) contains the user names
strUserName = arrUserPath(0)
strHomeDrive = "Z:"
strHomeDirPath = "\\server\" & strUserName
' Connect to the user account in AD
Set objUser = GetObject("WinNT://" & strUserName & "user")
'strTest = objUser.homedirectory
'wscript.echo strtest
If Err.Number <> 0 Then
outFile.writeline Now & vbTab & "Error connecting to " & strUserName & " --- " & Err.Description
Err.Clear
ErrorOccurred = True
Else
' Set the path for the account
On Error Resume Next
objUser.put "HomeDrive", "Z:"
On Error Goto 0
objUser.HomeDirectory = strHomeDirPath
objUser.SetInfo
If Err.Number <> 0 Then
outFile.writeline Now & vbTab & "Error setting home directory path for " & strUserName & " --- " & Err.Description
Err.Clear
ErrorOccurred = True
Else
outFile.writeline (Now & vbTab & "Home directory set for " & strUserName)
End If
End If
Wend
' Clean up the environment
outFile.writeline (Now & vbTab & "Ending script...")
inFile.close
outFile.close
If ErrorOccurred Then
msgbox "Script completed with errors. Please check the log file."
Else
MsgBox "Script completed successfully."
End If