Overwrite files without prompt with File.CopyHere in logon script (vbs)

logon-scriptsvbscriptwindows-server-2008

I'm trying to create a logon script (vbs) to install some fonts. If the fonts are installed I get a prompt saying "There's already a file with the same name in this location".

How can I force the files to be replaced without the prompt?

My script looks like this:

Const FONTS = &H14&


Const FOF_SILENT = &H4&
Const FOF_RENAMEONCOLLISION = &H8&
Const FOF_NOCONFIRMATION = &H10&
Const FOF_ALLOWUNDO = &H40&
Const FOF_FILESONLY = &H80&
Const FOF_SIMPLEPROGRESS = &H100&
Const FOF_NOCONFIRMMKDIR = &H200&
Const FOF_NOERRORUI = &H400&
Const FOF_NOCOPYSECURITYATTRIBS = &H800&
Const FOF_NORECURSION = &H1000&
Const FOF_NO_CONNECTED_ELEMENTS = &H2000&


cFlags = FOF_SILENT + FOF_NOCONFIRMATION + FOF_NOERRORUI

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FONTS)
objFolder.CopyHere "\\SERVER01\Fonts\*", cFlags

MSDN suggest (16) Respond with "Yes to All" for any dialog box that is displayed. but doesn't prevent the prompt.

(I'm using Windows Server 2008)

http://msdn.microsoft.com/en-us/library/windows/desktop/bb787866(v=vs.85).aspx

Best Answer

I think youv'e got the flags right, but try invoking CopyFolder against the Filesystem object.
Highly recommend the following for VBscript reference.
http://www.microsoft.com/download/en/details.aspx?id=2764

object.CopyFolder ( source, destination[, overwrite] );
Arguments
object 
Required. Always the name of a FileSystemObject. 
source 
Required. Character string folder specification, which can include wildcard characters, for one or more folders to be copied. 
destination 
Required. Character string destination where the folder and subfolders from source are to be copied. Wildcard characters are not allowed. 
overwrite 
Optional. Boolean value that indicates if existing folders are to be overwritten. If true, files are overwritten; if false, they are not. The default is true. 
Remarks
Wildcard characters can only be used in the last path component of the source argument. For example, you can use: 

[VBScript]
FileSystemObject.CopyFolder "c:\mydocuments\letters\*", "c:\tempfolder\"
Related Topic