#1 12 Feb 2013 18:58

WatPharma
New Member
Registered: 12 Feb 2013
Posts: 2

Modifying my VB Script to Read exclusions from a text file

I have been looking around and cant quite fine an easy way to integrate my file and folder exclusions from a txt file. at the moment i am entering each one as needed, but i know and feel that its getting sloppier everyday.  well below is the script that i currenltly use "im surprised it works, LOL".
as you see below all my file and folder exclusions are getting pretty messy.

if anyone can help me upgrading my script to read my exclusions from a single or multiple text files you guys would be my hero's


Set objShell = CreateObject("Wscript.Shell") 

objSource = InputBox("Please enter the Path to the source Data: Example:  C:\Source\Data", _
    "Source Folder")
If objSource = "" Then
    Wscript.Quit
Else
    Wscript.Echo objSource
End If

objDestination = InputBox("Please enter the Path to Destination Folder: Example:  C:\Target\Data", _
    "Destination Folder")
If objDestination = "" Then
    Wscript.Quit
Else
    Wscript.Echo objDestination
End If

objdate1 = InputBox("Only get files Newer than yyyymmdd:" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Example:  20121126", _
    "Files Newer Than Date")
If objdate1 = "" Then
    Wscript.Quit
Else
    Wscript.Echo objdate1
End If

objdate2 = InputBox("Only get files Older than yyyymmdd:" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Example:  20121126", _
    "Files Older Than Date")
If objdate2 = "" Then
    Wscript.Quit
Else
    Wscript.Echo objdate2
End If

objlogpath = InputBox("Please enter the Path and name of the existing log folder: Example:  C:\LogFolder\logname.txt" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "LOG FILE MUST HAVE A .TXT EXTENSION", _
    "Log Path and Folder Folder")
If objlogpath = "" Then
    Wscript.Quit
Else
    Wscript.Echo objlogpath
End If

objcmd = "Robocopy"
objSource = """" & objSource & """"
objDestination = """" & objDestination & """"
objdate1 = "" & objdate1 & ""
objdate2 = "" & objdate2 & ""
objswitches = " /B /E /A-:SH /COPY:DATO /R:2 /W:5 /V /TEE /XJ "
ExcludeDir = Chr(32) & Chr(34) & "Windows" & Chr(34) & Chr(32) & Chr(34) & "Program Files" & Chr(34) & Chr(32) & Chr(34) & "blackberry" & Chr(34) & Chr(32) & Chr(34) & "Temporary Internet Files" & Chr(34) & Chr(32) & Chr(34) & "Cookies" & Chr(34) & Chr(32) & Chr(34) & "Application Data" & Chr(34) & Chr(32) & Chr(34) & "Favorites" & Chr(34) & Chr(32) & Chr(34) & "IECompatCache" & Chr(34) & Chr(32) & Chr(34) & "IETldCache" & Chr(34) & Chr(32) & Chr(34) & "Local Settings" & Chr(34) & Chr(32) & Chr(34) & "PrintHood" & Chr(34) & Chr(32) & Chr(34) & "PrivacIE" & Chr(34) & Chr(32) & Chr(34) & "SendTo" & Chr(34) & Chr(32) & Chr(34) & "Start Menu" & Chr(34) & Chr(32) & Chr(34) & "Templates" & Chr(34) & Chr(32) & Chr(34) & "Tracing" & Chr(34) & Chr(32) & Chr(34) & "Altiris" & Chr(34) & Chr(32) & Chr(34) & "Apps" & Chr(34) & Chr(32) & Chr(34) & "DRIVERS" & Chr(34) & Chr(32) & Chr(34) & "Program Files" & Chr(34) & Chr(32) & Chr(34) & "WINNT" & Chr(34) & Chr(32) & Chr(34) & "Adobe" & Chr(34) & Chr(32) & Chr(34) & "Intel" & Chr(34) & Chr(32) & Chr(34) & "RECYCLER" & Chr(34) & Chr(32) & Chr(34) & "Bluetooth Software" & Chr(34) & Chr(32) & Chr(34) & "UserData" & Chr(34) & Chr(32) & Chr(34) & "AuthLog" & Chr(34) & Chr(32) & Chr(34) & "I386" & Chr(34) & Chr(32) & Chr(34) & "Tools" & Chr(34) & Chr(32) & Chr(34) & "Acc2k7" & Chr(34) & Chr(32) & Chr(34) & "InterWise" & Chr(34) & Chr(32) & Chr(34) & "Lync Recordings" & Chr(34) & Chr(32) & Chr(34) & "Administrator" & Chr(34) & Chr(32) & Chr(34) & "All Users" & Chr(34) & Chr(32) & Chr(34) & "default user" & Chr(34) & Chr(32) & Chr(34) & "LocalService" & Chr(34) & Chr(32) & Chr(34) & "NetworkService" & Chr(34) & Chr(32) & Chr(34) & "My Videos" & Chr(34) & Chr(32) & Chr(34) & "My Music" & Chr(34) & Chr(32) & Chr(34) & "My Pictures" & Chr(34) & Chr(32) & Chr(34) & "Access Connections" & Chr(34) & Chr(32) & Chr(34) & "My Shapes" & Chr(34) & Chr(32) & Chr(34) & "Tracing" & Chr(34) & Chr(32) & Chr(34) & "QUARANTINE" & Chr(34) & Chr(34) & Chr(32) & Chr(34) & "Lync" & Chr(34) & Chr(32) & Chr(34) & "AT&T Connect" & Chr(34) & Chr(32) & Chr(34) & "AT&T Web Meeting" & Chr(34) & Chr(32) & Chr(34) & "Bluetooth Exchange Folder" & Chr(34) & Chr(32) & Chr(34) & "My PSP Files" & Chr(34) & Chr(32) & Chr(34) & "SAP" & Chr(34) & Chr(32) & Chr(34) & "TurboTax" & Chr(34) & Chr(32) & Chr(34) & "Temp" & Chr(34) & Chr(32) & Chr(34) & "Updater" & Chr(34) & Chr(32) & Chr(34) & "preboot" & Chr(34) & Chr(32) & Chr(34) & "COnfig.MSI" & Chr(34) & Chr(32) & Chr(34) & "NetHood" & Chr(34) & Chr(32) & Chr(34) & "NetworkService" & Chr(34) & Chr(32) & Chr(34) & "System Volume Information" & Chr(34) & Chr(32) & Chr(34) & "MSOCache" & Chr(34) & Chr(32) & Chr(34) & "sys-servicenow-001" & Chr(34) & Chr(32) & Chr(34) & "sys-altiris-002.WATSON_DOMAIN" & Chr(34) & Chr(32) & Chr(34) & "sys-deploy-001.Watson_Domain" & Chr(34) & Chr(32) & Chr(34) & "Outlook" & Chr(34) & Chr(32) & Chr(34) & "Local Settings" & Chr(34) & Chr(32) & Chr(34) & "itunes" & Chr(34) & Chr(32) & Chr(34) & "i386" & Chr(34) & Chr(32) & Chr(34) & "amd64" & Chr(34) & Chr(32) & Chr(34) & "minint" & Chr(34) & Chr(32) & Chr(34) & "rrbackups" & Chr(34)
objExcludeDir = "/XD" & ExcludeDir

ExcludeFile = Chr(32) & Chr(34) & "*.ldr" & Chr(34) & Chr(32) & Chr(34) & "*.cfg" & Chr(34) & Chr(32) & Chr(34) & "*.dat" & Chr(34) & Chr(32) & Chr(34) & "*.BAT" & Chr(34) & Chr(32) & Chr(34) & "*.log" & Chr(34) & Chr(32) & Chr(34) & "*.SYS" & Chr(34) & Chr(32) & Chr(34) & "*.COM" & Chr(34) & Chr(32) & Chr(34) & "*.dmp" & Chr(34) & Chr(32) & Chr(34) & "*.ini" & Chr(34) & Chr(32) & Chr(34) & "*.dll" & Chr(34) & Chr(32) & Chr(34) & "*.pol" & Chr(34) & Chr(32) & Chr(34) & "*.exe" & Chr(34) & Chr(32) & Chr(34) & "*.mp3" & Chr(34) & Chr(32) & Chr(34) & "*.mp4" & Chr(34) & Chr(32) & Chr(34) & "*.mpg" & Chr(34) & Chr(32) & Chr(34) & "*.mpeg" & Chr(34) & Chr(32) & Chr(34) & "*.lnk" & Chr(34) & Chr(32) & Chr(34) & "*.abi" & Chr(34) & Chr(32) & Chr(34) & "*.adi" & Chr(34) & Chr(32) & Chr(34) & "*.abs" & Chr(34) & Chr(32) & Chr(34) & "*.adm" & Chr(34) & Chr(32) & Chr(34) & "*.accdb" & Chr(34) & Chr(32) & Chr(34) & "*.accdc" & Chr(34) & Chr(32) & Chr(34) & "*.accde" & Chr(34) & Chr(32) & Chr(34) & "*.accdr" & Chr(34) & Chr(32) & Chr(34) & "*.accdt" & Chr(34) & Chr(32) & Chr(34) & "*.accdu" & Chr(34) & Chr(32) & Chr(34) & "*.accdw" & Chr(34) & Chr(32) & Chr(34) & "*.accft" & Chr(34) & Chr(32) & Chr(34) & "*.log" & Chr(34) & Chr(32) & Chr(34) & "*.mav" & Chr(34) & Chr(32) & Chr(34) & "*.mdb" & Chr(34) & Chr(32) & Chr(34) & "*.mdbx" & Chr(34) & Chr(32) & Chr(34) & "*.mde" & Chr(34) & Chr(32) & Chr(34) & "*.mdf" & Chr(34) & Chr(32) & Chr(34) & "*.mdt" & Chr(34) & Chr(32) & Chr(34) & "*.mdx" & Chr(34) & Chr(32) & Chr(34) & "*.odb" & Chr(34) & Chr(32) & Chr(34) & "*.oedb" & Chr(34) & Chr(32) & Chr(34) & "*.db" & Chr(34) & Chr(32) & Chr(34) & "*.trc" & Chr(34) & Chr(32) & Chr(34) & "*.thmx" & Chr(34) & Chr(32) & Chr(34) & "*.odc" & Chr(34) & Chr(32) & Chr(34) & "*.bbb" & Chr(34) & Chr(32) & Chr(34) & "*.nsf" & Chr(34) & Chr(32) & Chr(34) & "*.ntf" & Chr(34) & Chr(32) & Chr(34) & "*.nbf" & Chr(34) & Chr(32) & Chr(34) & "*.id" & Chr(34) & Chr(32) & Chr(34) & "*.gif" & Chr(34) & Chr(32) & Chr(34) & "*.mdm" & Chr(34) & Chr(32) & Chr(34) & "*.dsk" & Chr(34) & Chr(32) & Chr(34) & "*.ncf" & Chr(34) & Chr(32) & Chr(34) & "*.med" & Chr(34) & Chr(32) & Chr(34) & "*.dic" & Chr(34) & Chr(32) & Chr(34) & "*.pst" & Chr(34) & Chr(32) & Chr(34) & "*.ost" & Chr(34) & Chr(32) & Chr(34) & "*.cnf" & Chr(34) & Chr(32) & Chr(34) & "*.ndk" & Chr(34) & Chr(32) & Chr(34) & "*.rnd" & Chr(34) & Chr(32) & Chr(34) & "*.hst" & Chr(34) & Chr(32) & Chr(34) & "*.njf" & Chr(34) & Chr(32) & Chr(34) & "*.box" & Chr(34) & Chr(32) & Chr(34) & "*.adr" & Chr(34) & Chr(32) & Chr(34) & "*.tab" & Chr(34) & Chr(32) & Chr(34) & "*.idt" & Chr(34) & Chr(32) & Chr(34) & "*.scr" & Chr(34) & Chr(32) & Chr(34) & "*.mov" & Chr(34) & Chr(32) & Chr(34) & "*.wmv" & Chr(34) & Chr(32) & Chr(34) & "*.dbf" & Chr(34) & Chr(32) & Chr(34) & "*.reg" & Chr(34) & Chr(32) & Chr(34) & "*.vcs" & Chr(34) & Chr(32) & Chr(34) & "*.mpp" & Chr(34) & Chr(32) & Chr(34) & "*.rdp"& Chr(34) & Chr(32) & Chr(34) & "*.htc" & Chr(34) & Chr(32) & Chr(34) & "*.ico" & Chr(34) & Chr(32) & Chr(34) & "*.inf" & Chr(34) & Chr(32) & Chr(34) & "*.cat" & Chr(34) & Chr(32) & Chr(34) & "*.emf" & Chr(34) & Chr(32) & Chr(34) & "*.dmg" & Chr(34) & Chr(32) & Chr(34) & "*.loc" & Chr(34) & Chr(32) & Chr(34) & "*.vbs" & Chr(34) & Chr(32) & Chr(34) & "*.xsd" & Chr(34) & Chr(32) & Chr(34) & "*.nfo" & Chr(34) & Chr(32) & Chr(34) & "*.bin" & Chr(34) & Chr(32) & Chr(34) & "*.xsl" & Chr(34) & Chr(32) & Chr(34) & "*.one" & Chr(34) & Chr(32) & Chr(34) & "*.out" & Chr(34) & Chr(32) & Chr(34) & "*.gp_" & Chr(34) & Chr(32) & Chr(34) & "*.gpd" & Chr(34) & Chr(32) & Chr(34) & "*.icm" & Chr(34) & Chr(32) & Chr(34) & "*.hl_" & Chr(34) & Chr(32) & Chr(34) & "*.dl_" & Chr(34) & Chr(32) & Chr(34) & "*.img" & Chr(34) & Chr(32) & Chr(34) & "*.azw" & Chr(34) & Chr(32) & Chr(34) & "*.mbp" & Chr(34) & Chr(32) & Chr(34) & "*.lpr" & Chr(34) & Chr(32) & Chr(34) & "*.phl" & Chr(34) & Chr(32) & Chr(34) & "*.wav" & Chr(34)
objExcludeFile = "/XF" & ExcludeFile

objage1 = "/MAXAGE:" & objdate1

objage2 = "/MINAGE:" & objdate2

objlogpath = "/log:" & objlogpath

objCommand = objcmd & Chr(32) & objSource & Chr(32) & objDestination & Chr(32) & objswitches & Chr(32) & objExcludeDir & Chr(32) & objExcludeFile & Chr(32) & objage1 & Chr(32) & objage2 & Chr(32) & objlogpath

Wscript.echo objcmd & Chr(32) & objSource & Chr(32) & objDestination & Chr(32) & objswitches & Chr(32) & objlogpath & Chr(32) & objage1 & Chr(32) & objage2

objShell.Run(objCommand)

MsgBox "Robo Script 5000 has been executed"

Offline

#2 12 Feb 2013 19:10

WatPharma
New Member
Registered: 12 Feb 2013
Posts: 2

Re: Modifying my VB Script to Read exclusions from a text file

here is part of my log that has the exlcusions. as you can see what a pain it is and how ugly it looks. getting it to read from a text file would be so much nicer

Exc Files :   *.ldr
        *.cfg
        *.dat
        *.BAT
        *.log
        *.SYS
        *.COM
        *.dmp
        *.ini
        *.dll
        *.pol
        *.exe
        *.mp3
        *.mp4
        *.mpg
        *.mpeg
        *.lnk
        *.abi
        *.adi
        *.abs
        *.adm
        *.accdb
        *.accdc
        *.accde
        *.accdr
        *.accdt
        *.accdu
        *.accdw
        *.accft
        *.log
        *.mav
        *.mdb
        *.mdbx
        *.mde
        *.mdf
        *.mdt
        *.mdx
        *.odb
        *.oedb
        *.db
        *.trc
        *.thmx
        *.odc
        *.bbb
        *.nsf
        *.ntf
        *.nbf
        *.id
        *.gif
        *.mdm
        *.dsk
        *.ncf
        *.med
        *.dic
        *.pst
        *.ost
        *.cnf
        *.ndk
        *.rnd
        *.hst
        *.njf
        *.box
        *.adr
        *.tab
        *.idt
        *.scr
        *.mov
        *.wmv
        *.dbf
        *.reg
        *.vcs
        *.mpp
        *.rdp
        *.htc
        *.ico
        *.inf
        *.cat
        *.emf
        *.dmg
        *.loc
        *.vbs
        *.xsd
        *.nfo
        *.bin
        *.xsl
        *.one
        *.out
        *.gp_
        *.gpd
        *.icm
        *.hl_
        *.dl_
        *.img
        *.azw
        *.mbp
        *.lpr
        *.phl
        *.wav
        
Exc Dirs : Windows
        Program Files
        blackberry
        Temporary Internet Files
        Cookies
        Application Data
        Favorites
        IECompatCache
        IETldCache
        Local Settings
        PrintHood
        PrivacIE
        SendTo
        Start Menu
        Templates
        Tracing
        Altiris
        Apps
        DRIVERS
        Program Files
        WINNT
        Adobe
        Intel
        RECYCLER
        Bluetooth Software
        UserData
        AuthLog
        I386
        Tools
        Acc2k7
        InterWise
        Lync Recordings
        Administrator
        All Users
        default user
        LocalService
        NetworkService
        My Videos
        My Music
        My Pictures
        Access Connections
        My Shapes
        Tracing
        QUARANTINE"
        Lync
        AT&T Connect
        AT&T Web Meeting
        Bluetooth Exchange Folder
        My PSP Files
        SAP
        TurboTax
        Temp
        Updater
        preboot
        COnfig.MSI
        NetHood
        NetworkService
        System Volume Information
        MSOCache
        sys-servicenow-001
        Outlook
        Local Settings
        itunes
        i386
        amd64
        minint
        rrbackups

Offline

Board footer

Powered by FluxBB