Re: Unable to verify copied file
From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 10/22/04
- Next message: Torgeir Bakken \(MVP\): "Re: Script to create GPO link on OU"
- Previous message: BlueScreen: "How to script Group policy change"
- In reply to: R. Baker: "Unable to verify copied file"
- Next in thread: R. Baker: "Re: Unable to verify copied file"
- Reply: R. Baker: "Re: Unable to verify copied file"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 22 Oct 2004 17:23:56 +0200
R. Baker wrote:
> I'm a newb to vbscripting and need a bit of help. I need to copy a
> file from a server for which the actual filename will vary when copied
> (virus definition file). The file will always have a XDB extension
> though, and there's only ever one of these files on the server share.
> I can copy file to my client using the wshFSO.CopyFile with *.XDB as
> the argument. However, it is my understanding that you can't verify
> file copy with return codes from the CopyFile method. (If I'm wrong
> please correct me). So I tried a wshFSO.FileExists searching for
> *.XDB. I suspect it doesn't like wildcards in this instance, as I've
> been able to search for files if I use complete filenames, but not
> *.XDB.
>
> Is there another way to verify the exisistence of a file, or check
> that the file copy was successful?
Hi
I suggest you wrap cmd.exe's copy command instead:
'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")
sSourceDir = "T:\some folder on server here"
sTargetDir = "C:\some folder on computer here"
' Copy using wild card, and with overwrite, binary and verify switch set
' Supports spaces in folder/file names
sCmd = "%comspec% /c copy /y /b /v """ _
& sSourceDir & "\*.XDB"" """ & sTargetDir & "\"""
iRC = oShell.Run(sCmd, 0, True)
If iRC = 0 Then
WScript.Echo "Copy OK"
Else
WScript.Echo "Copy failed!"
End If
'--------------------8<----------------------
-- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx
- Next message: Torgeir Bakken \(MVP\): "Re: Script to create GPO link on OU"
- Previous message: BlueScreen: "How to script Group policy change"
- In reply to: R. Baker: "Unable to verify copied file"
- Next in thread: R. Baker: "Re: Unable to verify copied file"
- Reply: R. Baker: "Re: Unable to verify copied file"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|