Kaseya Community

Testing for a directory path

  • I am attempting to create a script that will purge the IMF Archive with files that date older than 10 days old.

    I have the script running, and working well; although I would like to create an "IF" statement to check to see if IMF is installed first.

    The easiest way for me to do this would be to test to see if the C:\Program Files\Exchsrvr\Mailroot\vsi 1\UceArchive exists, although I cannot test for directory existance for some reason, it wants to test for a specific file.
    I have tried *.eml although that doesnt work either.

    Any insite into what I am doing wrong would be great.

    Thanks in advance



    Script Name: IMF Purge Files
    Script Description: Purges files from the C:\Program Files\Exchsrvr\Mailroot\vsi 1\UceArchive directory if they are older than 10 days.

    IF Test File
    Parameter 1 : C:\Program Files\Exchsrvr\Mailroot\vsi 1\UceArchive\*.eml
    Exists :
    THEN
    Get Variable
    Parameter 1 : 10
    Parameter 2 :
    Parameter 3 : agentDrv
    OS Type : 9
    Write File
    Parameter 1 : #agentDrv#\IMFPurge.bat
    Parameter 2 : VSASharedFiles\Maintenance\IMFPurge\IMFPurge.bat
    OS Type : 9
    Execute File
    Parameter 1 : #agentDrv#\IMFPurge.bat
    Parameter 2 :
    Parameter 3 : 1
    OS Type : 9
    Write Script Log Entry
    Parameter 1 : IMF Archive Directory Purged
    OS Type : 9
    ELSE
    Write Script Log Entry
    Parameter 1 : Intelligent Message Filter is not installed.
    OS Type : 0

    Legacy Forum Name: Testing for a directory path,
    Legacy Posted By Username: quicktech
  • Not sure what IMF is? However when we uninstall an application we first check the registry to see if the key for the app exists.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: boudj
  • boudj
    Not sure what IMF is? However when we uninstall an application we first check the registry to see if the key for the app exists.



    Forgive me, it is Intelligent Message Filter for Exchange 2003.
    I dont think there is an uninstall line for it, but I will look

    I might be able to see if there is an uninstall string for the updates perhaps...

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: quicktech
  • Personally - I'd just run the script if it doesn't find the directory the script won't do anything at all ... so it will either clear the directory, or it will bomb because it doesn't exist.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: TBK Consulting
  • Got it... most apps will write to the registry. I believe the following key is necessary for IMF:
    HKEY_LOCAL_MACHINE\Software\Microsoft\Exchange\ContentFilter

    So if you check for this key you'll know if you need to uninstall it.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: boudj
  • boudj
    Got it... most apps will write to the registry. I believe the following key is necessary for IMF:
    HKEY_LOCAL_MACHINE\Software\Microsoft\Exchange\ContentFilter

    So if you check for this key you'll know if you need to uninstall it.


    Great thanks Boudj.
    It actually works quite well, just wanted to test for existance first.

    I have actually found that Registry string already, although the "UceArchive" directory doesnt exist if no spam has come in, this should be rare unless Exchange SP2 or IMF was just implemented.
    I will have to set this up on a case by case basis.

    Thanks boudj, let me know if you want the script; I was planning on posting it here when I tweak it.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: quicktech
  • Does anybody know of a way to test for existence of a directory the IF in Kaseya's script language? I would have expected that to be one of the most basic commands of any script language. I've tried the Test File function with wildcards (e.g. C:\Temp\*.*), but it evaluates as false.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: ReedMikel
  • ReedMikel
    Does anybody know of a way to test for existence of a directory the IF in Kaseya's script language? I would have expected that to be one of the most basic commands of any script language. I've tried the Test File function with wildcards (e.g. C:\Temp\*.*), but it evaluates as false.


    You can use C:\Temp\NUL

    Supposedly NUL is a hidden system file which is located in every directory. I believe it has worked for me in the past. Give it a try.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: GDRBrian
  • Test File exists C:\Temp\NUL worked like a charm - thanks!
    Now the hard part, committing that to memory Smile

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: ReedMikel
  • GDRBrian
    You can use C:\Temp\NUL

    Supposedly NUL is a hidden system file which is located in every directory. I believe it has worked for me in the past. Give it a try.


    Yep, that's the way to do it!

    Michael

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: RCS-Michael
  • Better yet, Kaseya script could add a "Test Directory" function - so that those of us with impaired memories won't have to remember this odd NUL workaround Smile

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: ReedMikel
  • Hi, since in the example you mentioned you are trying to clear the IMF archive FWIW thought you might be interested in a product we use.. works really well with SBS 2003 IMF

    http://www.n2comms.com/SmartIMF.html

    Cheers

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Steve Morris