Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - write unicode?? for FSO

Reply
 
Old 12-20-2008   #1 (permalink)
LJB


 
 

write unicode?? for FSO

I have a script I'm trying to use for starting NTBackup with different
backup settings (*.bks file) each day. I need to write the bks file from my
script before I call NTBackup. It appears the bks file is Unicode but when I
write Unicode with objFSO.CreateTextFile(sFolderPathspec & "\Backup.bks",
True, True).WriteLine "....." the file gets two extra bytes, FF FE, at the
beginning of the file which seem to interfere with NTBackup reading that
file. Does anyone know how I can write the file in the same format NTBackup
does when saving its settings?

thanks
LJB





My System SpecsSystem Spec
Old 12-21-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: write unicode?? for FSO


"LJB" <dustyb@xxxxxx> wrote in message
news:GHd3l.11106$c45.9631@xxxxxx
Quote:

>I have a script I'm trying to use for starting NTBackup with different
> backup settings (*.bks file) each day. I need to write the bks file from
> my
> script before I call NTBackup. It appears the bks file is Unicode but when
> I
> write Unicode with objFSO.CreateTextFile(sFolderPathspec & "\Backup.bks",
> True, True).WriteLine "....." the file gets two extra bytes, FF FE, at the
> beginning of the file which seem to interfere with NTBackup reading that
> file. Does anyone know how I can write the file in the same format
> NTBackup
> does when saving its settings?
>
> thanks
> LJB
Welcome to the world of ntbackup!
The following code snippet will read a binary file, then write the data to
another binary file. All you need to do is precede sString with $FF$FE
before writing the output file.
Set oInputFile = oFSO.GetFile(sInputName)
Set oOutputFile = oFSO.OpenTextFile(sOutputName, 2, True)
Set oData = oInputFile.OpenAsTextStream
sString = oData.Read(oInputFile.Size)
oOutputFile.Write(sString)


My System SpecsSystem Spec
Old 12-21-2008   #3 (permalink)
LJB


 
 

Re: write unicode?? for FSO


"Pegasus (MVP)" <I.can@xxxxxx> wrote in message
news:%23oIFST0YJHA.6108@xxxxxx
Quote:

>
> "LJB" <dustyb@xxxxxx> wrote in message
> news:GHd3l.11106$c45.9631@xxxxxx
Quote:

>>I have a script I'm trying to use for starting NTBackup with different
>> backup settings (*.bks file) each day. I need to write the bks file from
>> my
>> script before I call NTBackup. It appears the bks file is Unicode but
>> when I
>> write Unicode with objFSO.CreateTextFile(sFolderPathspec & "\Backup.bks",
>> True, True).WriteLine "....." the file gets two extra bytes, FF FE, at
>> the
>> beginning of the file which seem to interfere with NTBackup reading that
>> file. Does anyone know how I can write the file in the same format
>> NTBackup
>> does when saving its settings?
>>
>> thanks
>> LJB
>
> Welcome to the world of ntbackup!
> The following code snippet will read a binary file, then write the data to
> another binary file. All you need to do is precede sString with $FF$FE
> before writing the output file.
> Set oInputFile = oFSO.GetFile(sInputName)
> Set oOutputFile = oFSO.OpenTextFile(sOutputName, 2, True)
> Set oData = oInputFile.OpenAsTextStream
> sString = oData.Read(oInputFile.Size)
> oOutputFile.Write(sString)
>
>
Actually I need to remove the existing $FF$FE. The following worked.

Set oInputFile = objFSO.GetFile(sFolderPathspec & "\Backup.bks")
Set oData = oInputFile.OpenAsTextStream
sString = oData.Read(oInputFile.Size)
Set oOutputFile = objFSO.OpenTextFile(sFolderPathspec & "\Backup.bks", 2,
True)
oOutputFile.Write(mid(sString,3))

thanks


My System SpecsSystem Spec
Old 12-21-2008   #4 (permalink)
Pegasus \(MVP\)


 
 

Re: write unicode?? for FSO


"LJB" <xyz@xxxxxx> wrote in message
news:XTu3l.10015$Ei5.6203@xxxxxx
Quote:

>
> "Pegasus (MVP)" <I.can@xxxxxx> wrote in message
> news:%23oIFST0YJHA.6108@xxxxxx
Quote:

>>
>> "LJB" <dustyb@xxxxxx> wrote in message
>> news:GHd3l.11106$c45.9631@xxxxxx
Quote:

>>>I have a script I'm trying to use for starting NTBackup with different
>>> backup settings (*.bks file) each day. I need to write the bks file from
>>> my
>>> script before I call NTBackup. It appears the bks file is Unicode but
>>> when I
>>> write Unicode with objFSO.CreateTextFile(sFolderPathspec &
>>> "\Backup.bks",
>>> True, True).WriteLine "....." the file gets two extra bytes, FF FE, at
>>> the
>>> beginning of the file which seem to interfere with NTBackup reading that
>>> file. Does anyone know how I can write the file in the same format
>>> NTBackup
>>> does when saving its settings?
>>>
>>> thanks
>>> LJB
>>
>> Welcome to the world of ntbackup!
>> The following code snippet will read a binary file, then write the data
>> to another binary file. All you need to do is precede sString with $FF$FE
>> before writing the output file.
>> Set oInputFile = oFSO.GetFile(sInputName)
>> Set oOutputFile = oFSO.OpenTextFile(sOutputName, 2, True)
>> Set oData = oInputFile.OpenAsTextStream
>> sString = oData.Read(oInputFile.Size)
>> oOutputFile.Write(sString)
>>
>>
> Actually I need to remove the existing $FF$FE. The following worked.
>
> Set oInputFile = objFSO.GetFile(sFolderPathspec & "\Backup.bks")
> Set oData = oInputFile.OpenAsTextStream
> sString = oData.Read(oInputFile.Size)
> Set oOutputFile = objFSO.OpenTextFile(sFolderPathspec & "\Backup.bks", 2,
> True)
> oOutputFile.Write(mid(sString,3))
>
> thanks
Thanks for the feedback.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
how to get powershell to write to event log or write a log file? PowerShell
Write-Error doesn't write anyting PowerShell
The disk is write-protected. Remove the write-protection or... Vista General
newline in Write-Debug or Write-Verbose PowerShell
New Message - Unicode (UTF-8) Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46