I am getting a Path Not Found error on a path that I know is correct.
Can anyone tell me what I might be doing wrong?
Here is what the code looks like:

Dim FSO, Infile, YR, path

path = "\\server\depts\GAL\GALLogs\"
YR=DatePart("YYYY", Date)

set FSO = createObject("Scripting.FileSystemObject")

set Infile = FSO.OpenTextFile(path & YR & "\YrToDate\Email.log", 1,
False)

I have tried different methods of building the actual path in the
OpenTextFile line and have had no success. Any help or suggestions
would be greatly appreciated. Thanks in advance.

Chuck

Re: VBScript error: Please Help by Michael

Michael
Mon Jan 19 10:22:00 CST 2004

Chuck wrote:
> I am getting a Path Not Found error on a path that I know is correct.
> Can anyone tell me what I might be doing wrong?
> Here is what the code looks like:
>
> Dim FSO, Infile, YR, path
>
> path = "\\server\depts\GAL\GALLogs\"
> YR=DatePart("YYYY", Date)
>
> set FSO = createObject("Scripting.FileSystemObject")
>
> set Infile = FSO.OpenTextFile(path & YR & "\YrToDate\Email.log", 1,
> False)
>
> I have tried different methods of building the actual path in the
> OpenTextFile line and have had no success. Any help or suggestions
> would be greatly appreciated. Thanks in advance.
>
> Chuck

You syntax seems correct. See where the script is looking by adding a
message box.

msgbox path & YR & "\YrToDate\Email.log"

Check this path in explorer.

I would also recommend that you not use the word "path" as a variable
because it is a property. You should prefix your variables with the data
type, like sPath for your path string or oInFile for your file object etc.

--
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



Re: VBScript error: Please Help by Michael

Michael
Mon Jan 19 13:53:02 CST 2004

Chuck wrote:
> I am getting a Path Not Found error on a path that I know is correct.
> Can anyone tell me what I might be doing wrong?
> Here is what the code looks like:
>
> Dim FSO, Infile, YR, path
>
> path = "\\server\depts\GAL\GALLogs\"
> YR=DatePart("YYYY", Date)
>
> set FSO = createObject("Scripting.FileSystemObject")
>
> set Infile = FSO.OpenTextFile(path & YR & "\YrToDate\Email.log", 1,
> False)
>
> I have tried different methods of building the actual path in the
> OpenTextFile line and have had no success. Any help or suggestions
> would be greatly appreciated. Thanks in advance.


What's the host context for the script? WSH? ASP? ???

What's the security context?

In impersonated account scenarios (like server side ASP), you won't be able
to even see UNC paths (hence the path not found) unless you use clear text
credentials to pre-authenticate with the remote server...


--
Michael Harris
Microsoft.MVP.Scripting

Windows 2000 Scripting Guide
Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

TechNet Script Center Sample Scripts
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en


Re: VBScript error: Please Help by lbelloeil

lbelloeil
Mon Jan 19 16:38:08 CST 2004

I remember I had a lot of problem accesing remote folders.
The best way I found was to map a drive to the remote shared folder
then you can browse subfolders:

Sub mapdrive (driveletter, netshare)
On Error Resume Next
err.clear
wshNetwork.MapNetworkDrive driveletter, netshare
If err <> 0 Then
message = "Cannot connecte " & _
driveletter & " to " & netshare & _
" Cause : " & Err.Description
Else
message =message & driveletter & " connected to " & netshare &
vbCrlf
End If
'Call addlog(message)
End Sub

I think it' because the FileSystem object can only work on local
drives.
So you have to map network shares to bypass network adressing

Re: VBScript error: Please Help by Michael

Michael
Mon Jan 19 16:43:26 CST 2004

> I think it' because the FileSystem object can only work on local
> drives.
> So you have to map network shares to bypass network adressing


Not true - all FSO methods support UNC paths.


--
Michael Harris
Microsoft.MVP.Scripting

Windows 2000 Scripting Guide
Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

TechNet Script Center Sample Scripts
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en


Re: VBScript error: Please Help by creed_wsh

creed_wsh
Tue Jan 20 09:33:38 CST 2004

Thanks for all the suggestions. I will post another message later to
let you know if it works. Thanks again.

"Michael Harris \(MVP\)" <mikhar at mvps dot org> wrote in message news:<O5HUN2t3DHA.2056@TK2MSFTNGP10.phx.gbl>...
> > I think it' because the FileSystem object can only work on local
> > drives.
> > So you have to map network shares to bypass network adressing
>
>
> Not true - all FSO methods support UNC paths.
>
>
> --
> Michael Harris
> Microsoft.MVP.Scripting
>
> Windows 2000 Scripting Guide
> Microsoft® Windows®2000 Scripting Guide
> http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp
>
> TechNet Script Center Sample Scripts
> http://www.microsoft.com/downloads/release.asp?ReleaseID=38942
>
> WSH 5.6 documentation download
> http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

Re: VBScript error: Please Help by lbelloeil

lbelloeil
Tue Jan 20 13:18:40 CST 2004

Michael was right, this works :

Dim FSO, Infile, YR, path, txtData

path = "\\maison\lolo\Dev\Microsoft\WindowsScripts\WSH\FSO\"
YR=DatePart("YYYY", Date)

set FSO = createObject("Scripting.FileSystemObject")

Set Infile = FSO.OpenTextFile(path & YR & ".log", 1,False)
txtData = infile.readall
RetCode= msgbox(txtData,vbOkonly,"File")
Infile.close