Re: Unable to verify copied file

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 10/22/04


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


Relevant Pages

  • Re: Unable to verify copied file
    ... >> file from a server for which the actual filename will vary when copied ... and there's only ever one of these files on the server share. ... it is my understanding that you can't verify ... So I tried a wshFSO.FileExists searching for ...
    (microsoft.public.scripting.vbscript)
  • Re: Windows/Macro Language Info?
    ... Java scriptlets and servlets can also carry malware. ... other part of the HTTP server. ... PHP can deliver malware and coordinate attacks to precisely the ... server-side scripting languages are not. ...
    (comp.lang.cobol)
  • Re: fetch extension - use local filename from content-dispositionheader (new diff)
    ... Previously giving this non-argument -O flag would use the ... Now this flag takes an expected filename as an argument. ... if we make a mistake in the URL or if the server changes the mapping. ... +If the server sent a Content-Disposition header, the +.Fa content_disposition +field will contain the suggested local filename. ...
    (freebsd-current)
  • Re: Proxy Management Point - Service Unavailable
    ... Verify that the Task Scheduler is enabled. ... Verify that the SQL Server has named pipes enabled. ... If you are using the IIS lockdown tool on your IIS 5 servers be sure ... I've successfully turned up> a Management Point on the Central Site server. ...
    (microsoft.public.sms.admin)
  • Re: asrock, problem with nic after windows-boot - Exact Opposite issue the OP is having
    ... the "power switch" on the front panel, and the O/S would cleanly terminate ... before turning off the power. ... For shell scripting, start with the Bash-Prog-Intro-HOWTO ... X really doesn't belong on a server, ...
    (comp.os.linux.networking)