Need VBScript to skip Administrator Profile (and other system folders)
Posted on 2013-10-24
I located a good VBScript to delete an Internet shortcut from the Desktop of all user profiles. the script works great but I'm having trouble getting it to skip the Administrator profile along with All Users, Default Users, LocalServices and NetworkServices.
I know I need a "For" somewhere in there like this but I'm not sure where to drop it in and make sure it is smooth.
or Each subfolder In FSfolder.subfolders
If (subfolder.Name <> "All Users" And subfolder.Name <> "Default User"_
and subfolder.Name <> "LocalService" and subfolder.Name <> "NetworkService") Then
Below is the script:
START_IN = "C:\Backups"
PREFIX = "Picture Perfect 4 Client"
Set oFSO = CreateObject("Scripting.FileSystemObject")
ProcessSubFolders oFSO.GetFolder(START_IN), iCount
Sub ProcessSubFolders(oFolder, iCount)
Set cFiles = oFolder.Files
For Each oFile In cFiles
If Left(oFile.Name, Len(PREFIX)) = PREFIX Then
iCount = iCount + 1
For Each oSubFolder In oFolder.SubFolders
ProcessSubFolders oSubFolder, iCount
WScript.Echo "Files deleted: " & iCount