Home NT NT Syntax
NT Syntax : A few general bits of advice.

Propagating Null's - if an input is required - test that it is actually there.

Missing executables - if you call a resource kit utility make sure it's available on the machine where the batch will be running, also check you have the latest versions of any resource kit utilities.

Permissions - Make sure the user running the batch has permission to access any files/resources you call. This particularly applies to scheduled tasks which may run under different accounts.

Batch files can be saved with the extension .BAT or .CMD
The .BAT extension will run under Windows 95/MSDOS but the .CMD extension will only run under NT. It is therefore advisable to use .CMD if the script uses any NT specific commands.

Long file names - If a filename contains spaces you must surround it "with double quotes" Filenames that include quotes or brackets (') - these are legal filenames but they can cause problems.

Short file names - The order in which you create files will affect short 8.3 names
e.g.
echo abc > "a long file 1.txt"
echo abc > "a long file 3.txt"
echo abc > "a long file 2.txt"
DIR /x
:: will produce this:
ALONGF~1.TXT a long file 1.txt
ALONGF~3.TXT a long file 2.txt
ALONGF~2.TXT a long file 3.txt

If these files are now copied to another folder the 8.3 filenames will change, this is most likely to happen when upgrading server storage or restoring data from a backup.

Similarly for folders
md "a long folder 1"
md "a long folder 3"
md "a long folder 2"
DIR /x
:: will produce this:
ALONGF~1 a long folder 1
ALONGF~3 a long folder 2
ALONGF~2 a long folder 3

Again copying these to somewhere else will change the 8.3 names to:
ALONGF~1 a long folder 1
ALONGF~2 a long folder 2
ALONGF~3 a long folder 3

 See the Wildcards page for more long/short filename issues. 

To disable the use of 8.3 filenames [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
NtfsDisable8dot3NameCreation=0



Simon Sheppard
SS64.com