# If/Then/Else Batch query?



## MysticZ (Jun 17, 2005)

Hi guys,

I have written the below batch file which basically copies a folder of folders from the server to each users desktop. It works fine. However I want to add in a condition that only copies the files if:

C:\Program Files\Microsoft Business Solutions\Great Plains actually exists on the users desktop. So it will only copy files to people who have Great Plains installed, and for others who dont have it installed, it wont copy the files to them. I am thinking its a basic if/then/else but i dont know how to do it.

Eg. If the Great Plains folder exists, do the batch file, if it doesnt exist, dont do the batch file...thats all i want.

Anyone know how to do this?


Cheers

MysticZ


@ECHO OFF
SETLOCAL

SET _source=\\tberp\GP\

SET _dest="C:\Program Files\Microsoft Business Solutions\Great Plains"

SET _what= /B /SEC 
:: /B :: copy files in Backup mode. 
:: /SEC :: copy files with SECurity

SET _options=/R:0 /W:0 /LOG:MyLogfile.txt /NFL /NDL
:: /R:n :: number of Retries
:: /W:n :: Wait time between retries
:: /LOG :: Output log file
:: /NFL :: No file logging
:: /NDL :: No dir logging 

ROBOCOPY %_source% %_dest% %_what% %_options%


----------



## Squashman (Apr 4, 2003)

A quick google search and your answer is on this page.

http://www.robvanderwoude.com/if.html


----------

