srantheman
IS-IT--Management
Hello, we are currently going through a mail upgrade in the school district. One of the steps involved is to save everybody's current mailbox to the server as a .pst file. We are trying to use calcs.exe to change each file so that only us and the user has access to that file. I have used calcs to change folder permsissions but never on a single file. Below is a script that I have written and it runs fine but does not change the permissions on the individual file. Anybody got any suggestions.
Dim fso, folder, files, NewsFile,sFolder, oShell, sSysDir
dim WshNetwork
Dim FoldPerm1, Calcds, oFSO
sFolder = "c:\PST"
Set fso = CreateObject("Scripting.FileSystemObject")
set WshNetwork = CreateObject("Wscript.Network")
set oShell = CreateObject("Wscript.Shell")
Set NewFile = fso.CreateTextFile("c:\PST\FileList.txt", True)
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files
For each folderIdx In files
NewFile.WriteLine(folderIdx.Name)
Next
NewFile.Close
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim MyFile, FileName, TextLine
' Open the file for output.
FileName = "c:\PST\FileList.txt"
' Open the file for input.
Set MyFile = fspenTextFile(FileName, ForReading)
' Read from the file and display the results.
sSysDir = fso.GetSpecialFolder(1).path
If Right(sSysDir,1) <> "\" Then sSysDir = sSysDir & "\"
Calcds = sSysDir & "cacls.exe"
Do While MyFile.AtEndOfStream <> True
TextLine = MyFile.ReadLine
TextLine = UCase(TextLine)
Username= Replace(TextLine, ".PST", "")
FoldPerm1 = """" & Calcds &"""" & """C:\PST\""" & TextLine & " /E /T /C /G " & """Username""" & ":C"
oShell.Run FoldPerm1, 1 ,True
Wscript.Sleep 1000
Loop
MyFile.Close
fso.DeleteFile "C:\PST\FileList.txt
Dim fso, folder, files, NewsFile,sFolder, oShell, sSysDir
dim WshNetwork
Dim FoldPerm1, Calcds, oFSO
sFolder = "c:\PST"
Set fso = CreateObject("Scripting.FileSystemObject")
set WshNetwork = CreateObject("Wscript.Network")
set oShell = CreateObject("Wscript.Shell")
Set NewFile = fso.CreateTextFile("c:\PST\FileList.txt", True)
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files
For each folderIdx In files
NewFile.WriteLine(folderIdx.Name)
Next
NewFile.Close
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim MyFile, FileName, TextLine
' Open the file for output.
FileName = "c:\PST\FileList.txt"
' Open the file for input.
Set MyFile = fspenTextFile(FileName, ForReading)
' Read from the file and display the results.
sSysDir = fso.GetSpecialFolder(1).path
If Right(sSysDir,1) <> "\" Then sSysDir = sSysDir & "\"
Calcds = sSysDir & "cacls.exe"
Do While MyFile.AtEndOfStream <> True
TextLine = MyFile.ReadLine
TextLine = UCase(TextLine)
Username= Replace(TextLine, ".PST", "")
FoldPerm1 = """" & Calcds &"""" & """C:\PST\""" & TextLine & " /E /T /C /G " & """Username""" & ":C"
oShell.Run FoldPerm1, 1 ,True
Wscript.Sleep 1000
Loop
MyFile.Close
fso.DeleteFile "C:\PST\FileList.txt