If exist c:\exchange.bkf goto RUNTHIS
You can use the goto statement to say send the process to the end of a script where you have the :RUNTHIS and it will skip the rest of the login script until it reaches that label. Obviously you can create your own logic flow and even call other scripts using Call runthis2.bat etc... For example if exist c:\exchange.bkf Goto Exchangeexists Rest of login scripts assuming that exchange.bkf does not exist, if it does then it is skipping everything until it hits the :Exchangeexists copy \\server\support.lnk <file:///\\server\support.lnk> c:\users\desktop\support.lnk ntbackup.exe /options /path.... End (This prevents the script from running below this and hence not running :Exchangeexists) :Exchangeexists Call exchangeexists.bat or perhaps you just don't want to run anything and thus you could just put an "end" Maybe you need to run a common set of commands and exclude say initiating a backup if the file exists. You want to be able to add options without running through the whole script, you can create after each section a Goto area that will run your :Common scripts. Or perhaps you simply want nothing to happen if the backup is there but want the flexibility of changing it later. At the :DONOTRUNTHIS, just put END instead of GOTO. Stops the script cold. If exists c:\exchange.bkf goto DONOTRUNTHIS If not exist c:\exchange.bkf goto RUNTHIS :DONOTRUNTHIS Goto Common Or END (Script stops) :RUNTHIS Ntbackup.exe /options Goto Common :COMMON Net use p: \\server\public <file:///\\server\public> Copy x.exe p:\backups Etc Etc From: Joseph L. Casale [mailto:[EMAIL PROTECTED] Sent: Saturday, January 12, 2008 3:25 PM To: NT System Admin Issues Subject: RE: Batch file help IF EXIST / IF NOT EXIST And you might even kick it up a notch with GOTO/LABELS and ERRORLEVEL. Google for examples/explanations. jlc From: Oliver Marshall [mailto:[EMAIL PROTECTED] Sent: Saturday, January 12, 2008 1:16 PM To: NT System Admin Issues Subject: Batch file help Hi, Can anyone give a me a hand with a batch file ? Basically I need to do this; If the file c:\exchange.bkf exists then do this; Blah If the file c:\exchange.bkf DOESNT exist then do this; Blig End Olly ~ Upgrade to Next Generation Antispam/Antivirus with Ninja! ~ ~ <http://www.sunbelt-software.com/SunbeltMessagingNinja.cfm> ~
