hello,
I'm trying to create a folder on a local workstation and set permissions of this folder. This is my script:
Option Explicit
Dim objFSO, objFolder, objShell, strDirectory, intRunError, strUser
strDirectory = "c:\test test"
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Note If..Exists. Then, Else ... End If construction
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
WScript.Echo strDirectory & " already created "
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
WScript.Echo "Just created " & strDirectory
End If
If err.number = vbEmpty then
Set objShell = CreateObject("WScript.Shell")
objShell.run ("Explorer" &" " & strDirectory & "\" )
Else WScript.echo "VBScript Error: " & err.number
End If
If objFSO.FolderExists(strDirectory) Then
' Assign user permission to folder.
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " _
& strDirectory & " /c /e /g ""LocalAccess"":F ", 2, True)
If intRunError <> 0 Then
Wscript.Echo "Error assigning permissions to folder " & strDirectory
End If
End If
WScript.Quit
the script works fine if the folder name doesn't contain any spaces. But i want the script to create a folder in 'Program Files'. The folder creation works fine; the problem is setting the permission. Does anybody know what i am doing wrong here?
THNX ! :)