I just wonder if the commands launched after the tests aren't a little ... 'premature'. I mean :
2. Check for Existence of direcotry Option one, look for the attributes
code: --------------------------------------------------------------------------------
IF GetFileAttr( "C:\ScriptTest" ) & 16ELSE MD "C:\ScriptTest"ENDIF
--------------------------------------------------------------------------------
Is telling us that "C:\ScriptTest" is not a directory, but it could be a file. In this case, if we try to create such a folder, an error 183 would certainly occur.
Using EXIST to test for a folder
code: --------------------------------------------------------------------------------
IF (EXIST("C:\ScriptTest\nul") <> 1) MD "C:\ScriptTest"ENDIF
-------------------------------------------------------------------------------- If a file called C:\ScriptTest exists, the Exist() function returns 1, so the folder is not created. But it doesn't exist.
3. Look for a file existence Option 1
code: --------------------------------------------------------------------------------
IF EXIST("C:\ScriptTest\Program.exe")ELSE COPY @LSERVER+"Programs\Program.exe" "C:\ScriptTest"ENDIF
--------------------------------------------------------------------------------
Option 2
code: --------------------------------------------------------------------------------
IF (1 <> EXIST("C:\ScriptTest\Program.exe")) COPY @LSERVER+"Programs\Program.exe" "C:\ScriptTest"ENDIF
--------------------------------------------------------------------------------
If A folder named C:\ScriptTest\Program.exe exists, the copy won't be done (and couldn't be done) but this file doesn't exist.
Option 3
code: --------------------------------------------------------------------------------
IF (EXIST("C:\ScriptTest\Program") <> 1) COPY @LSERVER+"Programs\Program.exe" "C:\ScriptTest"ENDIF
If A file or a folder named C:\ScriptTest\Program exists, the copy won't be done but the file C:\ScriptTest\Program.Exe doesn't exist.
My conclusion would be these tests are certainly good for what the titles say (searching if xxx is a directory etc ...), but perhaps not for conclude we can or cannot create folders or copy files.
Am I wrong ?
|