What will this .bat file do?

Associate
Joined
3 Sep 2003
Posts
1,731
Location
Staffordshire
Could somebody tell me what this will do

Code:
FOR /F "tokens=*" %%D IN ('DIR "C:\Program Files\filename" /S /B') DO copy /Y "filename" "%%D"
I just want to make sure its not one of these malicious code that do unexpected things.

Thank you
 
It is going to do a dir of all files in "c:\program files\filename\" and it's /Sub dirs in a /Bare list format, so just list the file names.
If you drop to a CMD line and do the dir command, DIR "C:\Program Files\filename" /S /B, you'll see the list of files returned.

It will then copy "filename" to "the name of the files returned from the dir", automatically answering /Yes to the overwrite prompt.

If you ran it from "c:\program files" it would basically trash all the files under "c:\program files\filename" and start to fill up the HDD.
If you copy a folder to a file it will overwrite the file with the contents of the first level of the folder.

So no, I wouldn't run it.

Hope that kind of makes sense, it'd be a lot easier to show you than it is to explain it tbh but you could test it by creating a test folder with some data in it and then run the commands manually or edit that bat file.
I'm also basing this on what it would do under Vista, as that's what I'm on at the moment, and not sure what differences there are at the moment between different versions of dos/cmd.
 
Back
Top Bottom