bladedanny Posted October 13, 2009 Posted October 13, 2009 Hi all, What I'm trying to do is create a .bat or .vbs script that will copy a folder from the network to c:\program files. I can do this no problem, what I want to know is how can I copy the folder only if it doesn't already exist in c:\program files. I'm new to IF functions in scripts so any help is welcomed. Also if possible I would prefer a .bat file rather than .vbs. Thanks, Dan
maniac Posted October 13, 2009 Posted October 13, 2009 This should do the trick - it's VBS script. Const OverWriteFiles = True Set objFSO = CreateObject("Scripting.FileSystemObject") If Not objFSO.FolderExists("c:\folder\path\here") then objFSO.CopyFolder "\\server\share\foldername" , "C:\folder\path\here" , OverWriteFiles End if 1
bladedanny Posted October 13, 2009 Author Posted October 13, 2009 Thanks, both work great, I have gone for the VBS one as I have heard they are better? Only reason I asked for .bat is because I have more knowledge of .bats. Thanks, Dan
srochford Posted October 13, 2009 Posted October 13, 2009 vbscript has more facilities available (particularly when you start working with COM objects like the filesystem, network, shell, active directory and so on) than batch language and I find it way more readable batch language used to be good because you could be sure that a command interpreter was always available but given that vbscript has been standard on Windows since IE4 came out you can be pretty sure it's going to be available on most machines. There are arguments for doing it all in something like Perl - you've then got a pretty cross platform language. I'm afraid I don't accept those arguments; Perl is a nightmare language for people with brains far bigger than me :-) 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now