EDN Admin
Well-known member
Hi All, <br/>
I have a script that I will post below which is working in regards <br/>
to deleting files more than two days old in the <span id="x_IL_AD4 directory specified in the root of C:. My issue is that the
<br/>
files I need to be deleted are within a user profile (My <span id="x_IL_AD5 Pictures)and I need
<span id="x_IL_AD1 the script to remove these files from over 250 different
<br/>
profiles and Im unsure of how to script this. For example with a batch script I <br/>
believe the path would be something along the lines of C:<span id="x_IL_AD11 Documents and Settings%userprofile%My Documents
<br/>
etc. The issue is I am unsure of the way to script this in VB i.e. the wildcard <br/>
for %userprofile%. <span><span>The script when complete will be <br/>
deployed to over 2000 clients with approx 250 profile names via SCCM and then a <br/>
scheduled task setup in <span id="x_IL_AD6 Group <br/>
Policy to run the script locally every couple of days from the <span id="x_IL_AD9
client. <br/>
<br/>
Any help would be much appreciated. Thanks <br/>
<br/>
<br/>
Script im using; <br/>
<br/>
Const strPath = "C:Test" <br/>
Dim objFSO <br/>
<br/>
Set objFSO = CreateObject("<span id="x_IL_AD8 Scripting.FileSystemObject")
<br/>
<br/>
Call Search (strPath) <br/>
<br/>
WScript.Echo"Done." <br/>
<br/>
Sub Search(str) <br/>
Dim objFolder, <br/>
objSubFolder, objFile <br/>
Set objFolder = objFSO.GetFolder(str) <br/>
For Each <br/>
objFile In objFolder.Files <br/>
If objFile.DateLastModified < (Now() - 2) <br/>
Then <br/>
objFile.Delete(True) <br/>
End If <br/>
Next <br/>
For Each <br/>
objSubFolder In objFolder.SubFolders <br/>
Search(objSubFolder.Path) <br/>
<br/>
Files have been deleted, now see if <br/>
the <span id="x_IL_AD7 folder is empty. <br/>
If (objSubFolder.Files.Count = 0) Then <br/>
<br/>
objSubFolder.Delete True <br/>
End If <br/>
Next <br/>
End Sub
View the full article
I have a script that I will post below which is working in regards <br/>
to deleting files more than two days old in the <span id="x_IL_AD4 directory specified in the root of C:. My issue is that the
<br/>
files I need to be deleted are within a user profile (My <span id="x_IL_AD5 Pictures)and I need
<span id="x_IL_AD1 the script to remove these files from over 250 different
<br/>
profiles and Im unsure of how to script this. For example with a batch script I <br/>
believe the path would be something along the lines of C:<span id="x_IL_AD11 Documents and Settings%userprofile%My Documents
<br/>
etc. The issue is I am unsure of the way to script this in VB i.e. the wildcard <br/>
for %userprofile%. <span><span>The script when complete will be <br/>
deployed to over 2000 clients with approx 250 profile names via SCCM and then a <br/>
scheduled task setup in <span id="x_IL_AD6 Group <br/>
Policy to run the script locally every couple of days from the <span id="x_IL_AD9
client. <br/>
<br/>
Any help would be much appreciated. Thanks <br/>
<br/>
<br/>
Script im using; <br/>
<br/>
Const strPath = "C:Test" <br/>
Dim objFSO <br/>
<br/>
Set objFSO = CreateObject("<span id="x_IL_AD8 Scripting.FileSystemObject")
<br/>
<br/>
Call Search (strPath) <br/>
<br/>
WScript.Echo"Done." <br/>
<br/>
Sub Search(str) <br/>
Dim objFolder, <br/>
objSubFolder, objFile <br/>
Set objFolder = objFSO.GetFolder(str) <br/>
For Each <br/>
objFile In objFolder.Files <br/>
If objFile.DateLastModified < (Now() - 2) <br/>
Then <br/>
objFile.Delete(True) <br/>
End If <br/>
Next <br/>
For Each <br/>
objSubFolder In objFolder.SubFolders <br/>
Search(objSubFolder.Path) <br/>
<br/>
Files have been deleted, now see if <br/>
the <span id="x_IL_AD7 folder is empty. <br/>
If (objSubFolder.Files.Count = 0) Then <br/>
<br/>
objSubFolder.Delete True <br/>
End If <br/>
Next <br/>
End Sub
View the full article