I have been using a script to transfer files from several remote servers on
a daily basis. Up till now the script has been functioning as it should,
however I noticed this morning that my script was generating the "Job
Finished" echo way too quickly so I checked the contents of the mapped
shares and found that the files were still there. After commenting out the
"On Error Resume Next" the following error popped up:





Error: File already exist.



Code: 800A003A

Source: Microsoft VBScript runtime error



The line that is referenced is the 'objFileSystemObject.CopyFile' portion
of Sub Transfer. While there are files in that New Directory that might have
the same name, why didn't the OverWriteFiles option ignore this?





Dim objWshNetwork, objWshShell

' On Error Resume Next

Set objWshNetwork = WScript.CreateObject("WScript.Network")

objWshNetwork.RemoveNetworkDrive "m:"

objWshNetwork.MapNetworkDrive "m:", "\\server\share"

Call Transfer

objWshNetwork.RemoveNetworkDrive "m:"

WScript.Echo "Test Finished!"



' Sub routine for moving Audit results from the local DC



Sub Transfer

Dim objFileSystemObject

Set objFileSystemObject = WScript.CreateObject("Scripting.FileSystemObject")

Set objFolder = objFileSystemObject.GetFolder ("m:\Data")

If objFolder.Files.Count > 0 Then

objFileSystemObject.CopyFile "m:\Data\*.xml",
"T:\New Directory\Data", OverWriteFiles

objFileSystemObject.DeleteFile "m:\Data\*.xml",
Force

End If

End Sub

Re: Script has stopped transfering files by Ulf

Ulf
Tue Nov 02 13:20:32 CST 2004

Just a quick shot:
Do you have the permission to delete/overwrite the existing files?

aptrsn wrote:
> I have been using a script to transfer files from several remote
> servers on a daily basis. Up till now the script has been functioning
> as it should, however I noticed this morning that my script was
> generating the "Job Finished" echo way too quickly so I checked the
> contents of the mapped shares and found that the files were still
> there. After commenting out the "On Error Resume Next" the following
> error popped up:
>
>
>
>
>
> Error: File already exist.
>
>
>
> Code: 800A003A
>
> Source: Microsoft VBScript runtime error
>
>
>
> The line that is referenced is the 'objFileSystemObject.CopyFile'
> portion of Sub Transfer. While there are files in that New Directory
> that might have the same name, why didn't the OverWriteFiles option
> ignore this?
>
>
>
>
>
> Dim objWshNetwork, objWshShell
>
> ' On Error Resume Next
>
> Set objWshNetwork = WScript.CreateObject("WScript.Network")
>
> objWshNetwork.RemoveNetworkDrive "m:"
>
> objWshNetwork.MapNetworkDrive "m:", "\\server\share"
>
> Call Transfer
>
> objWshNetwork.RemoveNetworkDrive "m:"
>
> WScript.Echo "Test Finished!"
>
>
>
> ' Sub routine for moving Audit results from the local DC
>
>
>
> Sub Transfer
>
> Dim objFileSystemObject
>
> Set objFileSystemObject =
> WScript.CreateObject("Scripting.FileSystemObject")
>
> Set objFolder = objFileSystemObject.GetFolder ("m:\Data")
>
> If objFolder.Files.Count > 0 Then
>
> objFileSystemObject.CopyFile "m:\Data\*.xml",
> "T:\New Directory\Data", OverWriteFiles
>
> objFileSystemObject.DeleteFile
> "m:\Data\*.xml", Force
>
> End If
>
> End Sub



Re: Script has stopped transfering files by Michael

Michael
Tue Nov 02 19:18:17 CST 2004

> The line that is referenced is the 'objFileSystemObject.CopyFile'
> portion of Sub Transfer. While there are files in that New Directory
> that might have the same name, why didn't the OverWriteFiles option
> ignore this?

Because OverWriteFiles is an undeclared variable with no assigned value. In
the context where you use it where a boolean argument is expected, its Empty
value will be coerced to False.

Add this...

Const OverWriteFiles = True



--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US


Re: Script has stopped transfering files by Ulf

Ulf
Tue Nov 02 19:51:55 CST 2004

Didn't he mentioned "Up till now the script has been functioning as it
should"?
So ... this couldn't be the problem.
;-))

Michael Harris (MVP) wrote:
> Because OverWriteFiles is an undeclared variable with no assigned
> value. In the context where you use it where a boolean argument is
> expected, its Empty value will be coerced to False.
>
> Add this...
>
> Const OverWriteFiles = True



Re: Script has stopped transfering files by Michael

Michael
Tue Nov 02 20:46:48 CST 2004

Ulf Dornheck Busscher wrote:
> Didn't he mentioned "Up till now the script has been functioning as
> it should"?
> So ... this couldn't be the problem.


Not necessarily... The OP's using wildcards in the file names (*.xml), not
expicit names. So you and I don't know if there have ever been any same
name matches until now, If not, then there would have been no overwrite
situations and the undefined OverWriteFiles would be irrelevant.

Unless the OP is hiding other parts of the actual script, the lack of a
defined True value for OverWriteFiles will result in exactly the error he
describes.


> ;-))
>
> Michael Harris (MVP) wrote:
>> Because OverWriteFiles is an undeclared variable with no assigned
>> value. In the context where you use it where a boolean argument is
>> expected, its Empty value will be coerced to False.
>>
>> Add this...
>>
>> Const OverWriteFiles = True

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US


Re: Script has stopped transfering files by aptrsn

aptrsn
Wed Nov 03 07:26:25 CST 2004

Yes, I run the script with Admin permissions.

"Ulf Dornheck Busscher" <ulfdb@web.de> wrote in message
news:%23DP%23GiQwEHA.1148@TK2MSFTNGP12.phx.gbl...
> Just a quick shot:
> Do you have the permission to delete/overwrite the existing files?
>
> aptrsn wrote:
> > I have been using a script to transfer files from several remote
> > servers on a daily basis. Up till now the script has been functioning
> > as it should, however I noticed this morning that my script was
> > generating the "Job Finished" echo way too quickly so I checked the
> > contents of the mapped shares and found that the files were still
> > there. After commenting out the "On Error Resume Next" the following
> > error popped up:
> >
> >
> >
> >
> >
> > Error: File already exist.
> >
> >
> >
> > Code: 800A003A
> >
> > Source: Microsoft VBScript runtime error
> >
> >
> >
> > The line that is referenced is the 'objFileSystemObject.CopyFile'
> > portion of Sub Transfer. While there are files in that New Directory
> > that might have the same name, why didn't the OverWriteFiles option
> > ignore this?
> >
> >
> >
> >
> >
> > Dim objWshNetwork, objWshShell
> >
> > ' On Error Resume Next
> >
> > Set objWshNetwork = WScript.CreateObject("WScript.Network")
> >
> > objWshNetwork.RemoveNetworkDrive "m:"
> >
> > objWshNetwork.MapNetworkDrive "m:", "\\server\share"
> >
> > Call Transfer
> >
> > objWshNetwork.RemoveNetworkDrive "m:"
> >
> > WScript.Echo "Test Finished!"
> >
> >
> >
> > ' Sub routine for moving Audit results from the local DC
> >
> >
> >
> > Sub Transfer
> >
> > Dim objFileSystemObject
> >
> > Set objFileSystemObject =
> > WScript.CreateObject("Scripting.FileSystemObject")
> >
> > Set objFolder = objFileSystemObject.GetFolder ("m:\Data")
> >
> > If objFolder.Files.Count > 0 Then
> >
> > objFileSystemObject.CopyFile "m:\Data\*.xml",
> > "T:\New Directory\Data", OverWriteFiles
> >
> > objFileSystemObject.DeleteFile
> > "m:\Data\*.xml", Force
> >
> > End If
> >
> > End Sub
>
>



Re: Script has stopped transfering files by aptrsn

aptrsn
Wed Nov 03 07:29:53 CST 2004

Is the Const declared in the begining of the Sub?

"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:uEPBBMUwEHA.1988@TK2MSFTNGP12.phx.gbl...
> > The line that is referenced is the 'objFileSystemObject.CopyFile'
> > portion of Sub Transfer. While there are files in that New Directory
> > that might have the same name, why didn't the OverWriteFiles option
> > ignore this?
>
> Because OverWriteFiles is an undeclared variable with no assigned value.
In
> the context where you use it where a boolean argument is expected, its
Empty
> value will be coerced to False.
>
> Add this...
>
> Const OverWriteFiles = True
>
>
>
> --
> Michael Harris
> Microsoft.MVP.Scripting
> Sammamish WA US
>



Re: Script has stopped transfering files by aptrsn

aptrsn
Wed Nov 03 07:36:17 CST 2004

Some more background infromation of the file transfer...

I found out that the normally when I run this script the destination
directory is empty because of a process that clears out the .xml files after
the last transfer. It turned out that the process had not been run so there
were in excess of 90 files still left in the directory. Once I ran this
process that cleared the destination directory, the script commenced without
problem. So for all practical purposes, I'm back to running normally.
However, I would still like to know why the file didn't force an
overwrite... even if the file name was the same.

"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:uQuoe9UwEHA.1976@TK2MSFTNGP09.phx.gbl...
> Ulf Dornheck Busscher wrote:
> > Didn't he mentioned "Up till now the script has been functioning as
> > it should"?
> > So ... this couldn't be the problem.
>
>
> Not necessarily... The OP's using wildcards in the file names (*.xml),
not
> expicit names. So you and I don't know if there have ever been any same
> name matches until now, If not, then there would have been no overwrite
> situations and the undefined OverWriteFiles would be irrelevant.
>
> Unless the OP is hiding other parts of the actual script, the lack of a
> defined True value for OverWriteFiles will result in exactly the error he
> describes.
>
>
> > ;-))
> >
> > Michael Harris (MVP) wrote:
> >> Because OverWriteFiles is an undeclared variable with no assigned
> >> value. In the context where you use it where a boolean argument is
> >> expected, its Empty value will be coerced to False.
> >>
> >> Add this...
> >>
> >> Const OverWriteFiles = True
>
> --
> Michael Harris
> Microsoft.MVP.Scripting
> Sammamish WA US
>



Re: Script has stopped transfering files by Michael

Michael
Wed Nov 03 20:34:25 CST 2004

aptrsn wrote:
> Some more background infromation of the file transfer...
>
> I found out that the normally when I run this script the destination
> directory is empty because of a process that clears out the .xml
> files after the last transfer. It turned out that the process had not
> been run so there were in excess of 90 files still left in the
> directory. Once I ran this process that cleared the destination
> directory, the script commenced without problem. So for all practical
> purposes, I'm back to running normally. However, I would still like
> to know why the file didn't force an overwrite... even if the file
> name was the same.


Please re-read my earlier replies...


>>
>>
>> Not necessarily... The OP's using wildcards in the file names
>> (*.xml), not expicit names. So you and I don't know if there have
>> ever been any same name matches until now, If not, then there would
>> have been no overwrite situations and the undefined OverWriteFiles
>> would be irrelevant.
>>
>> Unless the OP is hiding other parts of the actual script, the lack
>> of a defined True value for OverWriteFiles will result in exactly
>> the error he describes.
>>
>>
>>> ;-))
>>>
>>> Michael Harris (MVP) wrote:
>>>> Because OverWriteFiles is an undeclared variable with no assigned
>>>> value. In the context where you use it where a boolean argument is
>>>> expected, its Empty value will be coerced to False.
>>>>
>>>> Add this...
>>>>
>>>> Const OverWriteFiles = True
>>
>> --
>> Michael Harris
>> Microsoft.MVP.Scripting
>> Sammamish WA US

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US

Re: Script has stopped transfering files by Michael

Michael
Wed Nov 03 20:41:39 CST 2004

aptrsn wrote:
> Is the Const declared in the begining of the Sub?
>

You could do either in this case.

If you use it in only one sub/function, you can define it in the
sub/function where it is used. If you use it in more one place, you should
define it once globally so it can be used everywhere.

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US