Checking for Existence of a File or Directory

Creating the Initial File | Testing | Implementation

Basic Techniques: Mapping Drives | Connecting Printers | Section Labels

More Advanced Techniques: Group Membership For Mappings | Record Script Results | Location Detection | Machine ID | OS Detection |
Registry Changes | Redirection of IE Favourites | Existing File / Directory Check | Limit the Number of Network Logins a User Can Make

A useful technique is to check for the existence of a file or directory. You can then set actions on the result. This could be copying an update across, running an another application or just recording that something is installed. This can be achieved using the built in command line tools, as per the same script below.

In both examples the script will move on to the ":next" if the file or directory is found. You could change the "if exist" to "if not exist" if you want the script to react to something being missing as an alternative.

Checking for a file

In this example, the script is checking for a file called "content.txt" in the directory "example".

Checking for a Directory

This sample is checking for a directory called "content" which is a sub directory of "example"


Top of the Page - Home Page
Last Page Update: 08/03/2012

© Sembee Ltd. 1998 - 2012.

Reproduction of any content on this web site is prohibited without express written consent. Use of this web site is subject to our terms and conditions.

All trademarks and registered trademarks are property of their respective owners. This site is not endorsed or recommended by any company or organisation mentioned within and is to provide guidance only and as such we cannot be held responsible for any consequences of following the advice given.

Sembee Ltd. is registered in England and Wales at 33 Scrivens Mead, Thatcham, Berkshire, RG19 4FQ.
Registered company number: 4704428. VAT Number GB 904 5603 43.