dear vbs-ng, i could not find any help in the wsh-ng; may be you have an
idea:
the following script runs as a logon-script for a w2k3 domain for every
user. it creates a home-folder and should set the permission for the
administrator and the user. the permissions for the administrator are
correct, but the user who started the script during login, does not have any
rights. how can i give the user full right for its own home folder in a
script ?
thanx alot
tim
Dim WshNetwork, LogonUser
Set WshNetwork = WScript.CreateObject("WScript.Network")
Const WAIT_ON_RETURN = True
Const HIDE_WINDOW = 0
Const USER_ROOT_UNC = "\\server01\home$"
Const USER_ROOT_LOCAL = "D:\home"
LogonUser = WshNetwork.UserName
Call CreateHomeFolder(LogonUser)
Sub CreateHomeFolder(strUser)
Dim WshShell, objFS
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFS = CreateObject("Scripting.FileSystemObject")
Call objFS.CreateFolder(USER_ROOT_UNC & "\" & strUser)
Call WshShell.Run("cacls " & USER_ROOT_UNC & "\" & strUser & _
" /e /g Administrators:F", HIDE_WINDOW, WAIT_ON_RETURN)
'--> setting the users permission
Call WshShell.Run("cacls " & USER_ROOT_UNC & "\" & strUser & _
" /e /g " & strUser & ":F", HIDE_WINDOW, WAIT_ON_RETURN)
End Sub