Solved

Error running VBS

Posted on 2011-09-20
3
264 Views
Last Modified: 2012-05-12
I am trying to copy files to FolderA then move them to FolderB, but I get an VBScript error:




LINE 11
CHAR: 9
ERROR: Bad File name or number
Code 800A0034

See CODE BELOW...

strSourceFolder = "\\10.41.40.119\ercharts$"
strTargetFolderA = "\\10.41.40.119\ercharts$"
strTargetFolderB = "\\10.41.32.139\rootsftp$\MarinaMBS"

If Right(strSourceFolder, 1) <> "\" Then strSourceFolder = strSourceFolder & "\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set objSource = fso.GetFolder(strSourceFolder)
For Each oFile In objSource.Files
    strFirst8 = Left(oFile.Name, 8)
    If Not fso.FolderExists(strTargetFolderA & strFirst8) Then
        fso.CreateFolder strTargetFolderA & strFirst8
    End If
    fso.copyfile strSourceFolder & oFile.Name, strTargetFolderA & strFirst8 & "\"
    fso.MoveFile strSourceFolder & oFile.Name, strTargetFolderB & strFirst8 & "\"
Next

Open in new window

0
Comment
Question by:epicazo
3 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 125 total points
ID: 36570370
Hi, change this:
fso.CreateFolder strTargetFolderA & strFirst8

to this:
fso.CreateFolder strTargetFolderA & "\" & strFirst8

Rob.
0
 
LVL 6

Expert Comment

by:jorgedeoliveiraborges
ID: 36583856
Put a new Line 11 in order to debug, please.
msgbox strTargetFolderA & strFirst8
0
 

Author Closing Comment

by:epicazo
ID: 36588898
thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome to part one of a multi-part tutorial series, VBScript for Windows System Administrators.  The goal of this series is to teach non-programmers how to write useful VBS code to automate their environment, and perform tasks faster, and in a more…
Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now