Kaseya Community

Test for Existence of a Directory, Not a File

  • I'm looking for a way to test for the existence of a directory, not a file, within a procedure. The test also has to be variable, looking for the presence of a directory in %programfiles% and %programfiles(x86)%. Using Kaseya's file-existence IF step, but with "\nul" appended, does not work (it will fail to report the directory's existence even when it's there).

    As an alternative I tried having the procedure save the contents of a "dir" command to a text file, load the file's contents to a variable, then testing the variable for the existence of text within it, but that also does not work, for reasons I haven't been able to figure out.

    There must be some easier way than this ... but at the moment I have no idea what that could be.

    In case anyone's wondering what I'm doing ... the goal here is to detect the existence of Java on a computer so a procedure can be launched to update it. I'm avoiding installing it on machines that don't already have it. Suggesting KSDU as an alternative will not work, since we don't intend to pay for that, just so we can update Java, Flash, and Reader on computers. This is something that can be handled within a procedure, so I would like to do so.

  • Could you make a View for machines with Java installed and then apply any updates to those machines in the View?

  • I already have a view for machines with Java. And it's great to use it to schedule the procedure, I suppose. But the decision to run the update procedure or not for any given machine, has to be made at the time it's scheduled. But there's always a possibility I might add Java to a machine, or remove it from one. I then would have to specifically schedule or cancel the procedure for that machine.

    It'd be much better to do this programatically and cover all machines with it. This will ensure that machines which need Java updated always will be, and that it won't accidentally be installed where it doesn't belong.

  • This is what I do:

    Run this command to variable: wmic product get name

    If the variable contains "Java", proceed.

  • Thanks Lothario, that did it! I was pretty sure I was going about it the wrong way.

  • Be careful about what to check for - you may need to be more granular than just "Java". Or else you may pick up something with Java in the title...