1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| Dim oFSO,oFld
Set oFSO = CreateObject("Scripting.FileSystemObject")
Dossier = "c:\Essai"
DossierReadOnly = "c:\EssaiLectureSeule"
If Not oFSO.FolderExists(Dossier) Then
'Crée le repertoire c:\Essai
Set oFld=oFSO.CreateFolder(Dossier)
end if
If Not oFSO.FolderExists(DossierReadOnly) Then
'Crée le repertoire c:\EssaiLectureSeule
Set oFld=oFSO.CreateFolder(DossierReadOnly)
end if
Call ControlTotal(Dossier) 'Pour rendre le dossier en contrôle Totale
Call LectureSeule(DossierReadOnly) 'Pour rendre le dossier en lecture seule
Function LectureSeule(objet)
Set Ws = CreateObject("WScript.Shell")
Set ProcessEnv = Ws.Environment("Process")
NomUtilisateur = ProcessEnv("USERNAME")
Command = "%COMSPEC% /c Echo o| cacls "& objet &" /g " & qq(NomUtilisateur) & ":r administrateurs:r"
Result = ws.Run(Command,0,True) 'exécution de la commande sans afficher la console MS-DOS
End Function
Function ControlTotal(objet)
Set Ws = CreateObject("WScript.Shell")
Set ProcessEnv = Ws.Environment("Process")
NomUtilisateur = ProcessEnv("USERNAME")
Command = "%COMSPEC% /c Echo o| cacls "& objet &" /g " & qq(NomUtilisateur) & ":f administrateurs:f"
Result = ws.Run(Command,0,True) 'exécution de la commande sans afficher la console MS-DOS
End Function
Function qq(strIn)
qq = Chr(34) & strIn & Chr(34)
End Function |
Partager