VB File Copy script failing - TechRepublic
General discussion
June 28, 2006 at 12:01 AM
matt h

VB File Copy script failing

by matt h . Updated 20 years ago

Can anyone otut there tell me why this ain’t working? The echo’s are so I could see how far it was getting. I have a ‘Expected If’ error but have had all sorts. Need to be able to pass it the filename from the command line. It’ll be something really stupid I know, but I can’t see it. Not very good at VBS yet.

MAny thanks

Option Explicit

Dim strFilename
Dim fsoCopy
Dim strDestination

wscript.echo “…1”

strDestination = “\\192.168.xxx.xxx\Dropin\test\”
Set strFilename = WScript.Arguments(0)
Set fsoCopy = CreateObject(“Scripting.FileSystemObject”)

wscript.echo “…2”

If Instr(strFilename, “ian”) > 0 Then

wscript.echo “…2.1”

fsoCopy.CopyFile strFilename, strDestination & “ian”

wscript.echo “…3”

Else
If Instr(strFilename, “fred”) > 0 Then

wscript.echo “…3.1”

fsoCopy.CopyFile strFilename, strDestination & “fred”

wscript.echo “…3.2”

wscript.echo “…4”

Else
If Instr(strFilename, “malcolm”) > 0 Then
fsoCopy.CopyFile strFilename, strDestination & “malcolm”

wscript.echo “…5”

ElseIf inStr(strFilename, “test.exe”) > 0 Then
fsoCopy.CopyFile strFilename, strDestination & “test”

End If
wscript.echo “…” & strFilename

end

This discussion is locked

All Comments