Fixed code from old script; also, Win uses %FOO%, not $FOO