Michael
Wed Jul 16 22:08:10 CDT 2003
To add to Peters suggestion you can also do this
if fso.FolderExists(TargetFolder) then
In effect this line directly says that the file exists or is true
if not fso.FolderExists(TargetFolder) then
In effect this line directly says that the file does not exists or is false
--
Regards,
Michael Holzemer
No email replies please - reply in newsgroup
Learn script faster by searching here
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp
"Peter" <ap.lamb@ntlworld.com> wrote in message
news:HjoRa.28761$4O4.3360019@newsfep2-win.server.ntli.net...
> I would also suggest that you alter the
>
> "If fldExists = False Then"
>
> to
>
> "If Not(CBool(fldExists)) Then"
>
> Your fldExists is already a boolean and hence you don't need to check that
> it equals False. CBool will ensure that it comes out True or False. Using
> Not ensure that if it is False then the condition is true and vice versa.
>
> Peter.
>
> "Michael Holzemer" <ms2kguru@noway.pacbell.net> wrote in message
> news:u1Kdz6ATDHA.632@tk2msftngp13.phx.gbl...
> > If you comment the on error goto 0 and the on error resume next, your
> error
> > will pop up on the screen. You can also do something like
> >
> > if err.number <> 0 then
> > msgbox err.number & vbcrlf & err.description
> > end if
> >
> > to trap your error instead of the on error goto 0.
> >
> > --
> > Regards,
> >
> > Michael Holzemer
> > No email replies please - reply in newsgroup
> >
> > Learn script faster by searching here
> >
>
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcen
> ter/default.asp
> >
> >
> > "NPrasad" <anbarsha@yahoo.com> wrote in message
> > news:064801c34c04$ca8bb700$a301280a@phx.gbl...
> > > I have this script which is part of an installation
> > > script. The first time the script runs fine creates the
> > > Targetfolder and copies the files
> > > When I run the script again it says it completed with an
> > > error but how can I print this error to the screen to see
> > > what the error is? My question is Where is the error
> > > coming from if it does not enter the If loop?
> > >
> > > Thanks for the help!
> > >
> > > Dim fso, fldExists, SourceFolder, TargetFolder
> > > Set fso = CreateObject
> > > ("Scripting.FileSystemObject")
> > >
> > > On Error Resume Next
> > > fldExists = False
> > > fldExists = fso.FolderExists(TargetFolder)
> > > If fldExists = False Then
> > > On Error Goto 0
> > > fso.CreateFolder(TargetFolder)
> > > fso.CopyFolder SourceFolder, TargetFolder
> > > End If
> > > set fso = nothing
> >
> >
>
>