Re: Why can't I open two files in my script
- From: "Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 10 Jan 2006 11:06:24 -0600
Hi,
And just to add, you only need to create objFSO once. If you are opening two
files, then you cannot use objTextFile for both. Perhaps use objTextFile1
and objTextFile2.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
"/\/\o\/\/ [MVP]" <oMVP@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C8EE1D5A-E0ED-467C-A0F6-C25BB7CEF316@xxxxxxxxxxxxxxxx
>a couple of remarks.
>
> 1) the constant needs to be declared only once.
> 2) you should remove the On error resume next, to see the errors
> 3) you reuse the objTextfile, while you still need the old value
> (textfile)
> 4) the path in the second file is not valid.
>
> if it still not works after these changes please post the resulting error.
>
> gr /\/\o\/\/
>
>
> "Kevini" wrote:
>
>> I thought it would be simple as I have a txt file to read the computers
>> and I
>> want to go to each computer and open a txt file and pull out one line and
>> then send the results. I must have something wrong. It gets stuck athe
>> the
>> second Const Forreading
>>
>> Const ForReading = 1
>>
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> Set objTextFile = objFSO.OpenTextFile _
>> ("c:\computer.txt", ForReading)
>>
>> Do Until objTextFile.AtEndOfStream
>> strComputer = objTextFile.ReadLine
>> Wscript.Echo strComputer
>>
>> On error resume next
>> Const ForReading = 1
>>
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> Set objTextFile = objFSO.OpenTextFile("\C$\Program Files\Common
>> Files\Symantec Shared\VirusDefs\definfo.dat", ForReading)
>>
>> For i = 1 to 1
>> objTextFile.ReadLine
>> Next
>>
>> strLine = objTextFile.ReadLine
>> Wscript.Echo strLine
>>
>>
>>
>> Loop
>>
>> objTextFile.Close
>>
.
- Prev by Date: 'objWshShell.Exec
- Next by Date: Re: [MSH] accesing IADsLargeInteger
- Previous by thread: 'objWshShell.Exec
- Next by thread: RE: Why can't I open two files in my script
- Index(es):