Sobrescrever arquivos sem prompt com File.CopyHere no script de logon (vbs)

3

Estou tentando criar um script de logon (vbs) para instalar algumas fontes. Se as fontes estiverem instaladas, recebo uma mensagem dizendo "Já existe um arquivo com o mesmo nome neste local".

Como posso forçar a substituição dos arquivos sem o prompt?

Meu script é assim:

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

O MSDN sugere (16) Respond with "Yes to All" for any dialog box that is displayed. , mas não impede o prompt.

(estou usando o Windows Server 2008)

link

    
por Jonas Stensved 21.02.2012 / 14:17

1 resposta

0

Eu acho que você tem as bandeiras certas, mas tente invocar CopyFolder contra o objeto Filesystem.
Altamente recomende o seguinte para referência VBscript.
link

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\"
    
por 21.02.2012 / 16:34