我试图创build一个login脚本(VBS)来安装一些字体。 如果安装了字体,我会得到一个提示:“在这个位置已经有一个同名的文件了”。
如何在不提示的情况下强制replace文件?
我的脚本如下所示:
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
MSDNbuild议(16) Respond with "Yes to All" for any dialog box that is displayed. 但并不妨碍提示。
(我正在使用Windows Server 2008)
http://msdn.microsoft.com/en-us/library/windows/desktop/bb787866(v=vs.85).aspx
我认为youv'e得到了正确的标志,但尝试调用CopyFolder对Filesystem对象。
强烈推荐以下VBscript参考。
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\"