
Passing Value to VB Script
If you just want to read the data, you can read the first line of the file
(reading "by line" ensures that any odd linefeed characters are left out).
I have a function which acts like a clone of the "head" command to do things
like this; if you specify reading only 1 line, it returns it without a final
line feed.
sData = Head("C:\temp\rg3.reg", 1)
WScript.Echo sData
Function Head(fil, nlines)
'Given the path to a file, will return
' count nlines # of lines
' lines will be separated with vbCrLF if more than
' one is specified
' works with either ANSI or Unicode
Const ForReading = 1, TristateUseDefault = -2, _
DoNotCreateFile = False
With CreateObject("Scripting.FileSystemObject")._
OpenTextFile(fil, ForReading, _
False, TristateUseDefault)
for i = 1 to nlines
Head = Head & .ReadLine
if i < nlines then Head = Head & vbCrLf
Next
.Close
End With
End Function
Quote:
> Hi Gurus,
> I am quite new to VBScript and need some help regarding a VBScript I
> am writing.
> Problem.
> I have a file that contains only one line in it which is the date
> passed from anothe sources (Unix Box). the file contains the following
> 20020621
> How can I pass this value to a variable in the script so I can use it
> to create a folder with that value ?