I am writing script that will refresh a users environment (desktop and start menu) with master copies. Using wsh and vb I have a routine to replace the folders and files; but when ran on Vista the routine returns a runtime error: code 800A0046 Permission denied. Can anyone advise what I am missing to get the script to work?
The script is ran manually by an administrator user.
To try and overcome the premissions problem I run the following* before trying to remove the old files:
The routine is passed the username of the administrator, and F as the required rights. Although the intRunError returns 0, the rights on the the target folder do not appear to be changed (looking through Windows Explorer).
As a final sanity check I can complete the scripts tasks manually using Explorer. Doing this when I first attempt to open the target folder (eg the users desktop folder) Explorer first tells me I have no rights and asks me to confirm that I am an administrator, once this is done the rest of the tasks can be completed.
* Code based on recommendations in the posting "How to set folder permissions with VBScript
Function SetPermissions(strChangeFolder, strUser, strRights)
Dim intRunError, objShell, objFSO
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strChangeFolder) Then
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & _
strChangeFolder & " /e /c /g " & _
strUser & ":" & strRights, 2, True)
If intRunError <> 0 Then
reply = MsgBox ("Error assigning permissions for user " & strUser & Chr(13) & _
" to folder: " & Chr(13) & _
" on this forum (sorry - new to board so can't link yet)
Vista Business SP2 32-bit