Hi All,

I'm new to vbscripting and have an issue which I just can't figure
out. I'm hoping somebody here can set me straight.

My Dilemma,

When Appending to a text fil via my script, the text shows up as boxes
in Notepad instead of text. If I copy the text to MSWord or Excel i
see what looks like boxes and other crazy characters. Funny thing is
that when I write to the text file, I have no issues, the text comes
out clean. I'm sure it's my code that is jacked up, so please do fix
her up if you see a problem. I've also attempted specifying the format
as ASCII and get the same result.

Here's what I see in the text file

=E2=B5=84=E4=B5=81=C2=B5=C2=A5=E4=B1=93=E2=B5=83=E4=B1=82=E3=80=B0=E0=A4=B1=
=C5=BE=C2=BA=C3=87=C3=85=C2=AB@=C5=93=C2=AB=E3=8C=89=E3=88=AF=E2=BC=B9=E3=
=80=B2=E3=9C=B0=E3=8C=A0=E3=94=BA=E3=A8=B9=E3=A4=B0=E2=80=9A=E2=80=B9=E0=B5=
=8D

Here's my script, you'll notice this is an HTA so the interesting
section should be between <script Language=3D"VBScript"> and </script>

TIA

<head>
<title>Policy</title>
<HTA:APPLICATION
ID=3D"Policy"
APPLICATIONNAME=3D"Policy"
SCROLL=3D"yes"
SINGLEINSTANCE=3D"yes"
WINDOWSTATE=3D"normal"
>
</head>
<script language=3D"VBScript">

Option Explicit

Const USER_PROFILE =3D &H28&
Const ForReading =3D 1
Const ForWriting =3D 2
Const ForAppending =3D 8

Dim PolicyTextPath, PolicyFolderPath, PolicyUsername,
PolicyReportingPath, PolicyReportingTextPath, PolicyFileName,
PolicyReportingobjFile, _
PolicyTextobjFile, PolicyobjFSO, Policyarrcommands, PolicyobjNetwork,
PolicyobjFolderItem, PolicyobjShell, PolicyobjFolder,
PolicyobjComputer, _
objPolicyFSO, objPolicyFile, PolicyContents, TextstrWordList,
TextstrSearchWord, ReportingstrWordList, ReportingstrSearchWord,
PolicyReportingText, PolicyText

Set PolicyobjFSO =3D CreateObject("Scripting.FileSystemObject")
Set PolicyobjNetwork =3D CreateObject("Wscript.Network")
Set PolicyobjShell =3D CreateObject("Shell.Application")
Set PolicyobjFolder =3D PolicyobjShell.Namespace(USER_PROFILE)
Set PolicyobjFolderItem =3D PolicyobjFolder.Self
Set PolicyobjComputer =3D CreateObject("Shell.LocalMachine")
Set PolicyobjShell =3D CreateObject("Shell.Application")
'Wscript.Echo PolicyobjFolderItem.Path
PolicyReportingPath =3D "\\blabkup\softwaredeployment\policies\Reporting
\"
PolicyFolderPath =3D PolicyobjFolderItem.Path & "\policy"
PolicyUsername =3D PolicyobjNetwork.Username
Sub Window_onLoad
Policyarrcommands =3D Split(Policy.commandLine, chr(34))
PolicyFileName =3D Policyarrcommands(3)
PolicyTextPath =3D PolicyobjFolderItem.Path & "\policy\" &
PolicyFileName & ".txt"
PolicyReportingTextPath =3D PolicyReportingPath & PolicyFileName &
"=2Etxt"
Call PolicyPath
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub PolicyPath
Dim PolicyPath
PolicyPath =3D "\\blabkup\softwaredeployment\policies\Policy\" &
PolicyFileName & ".txt"
Set objPolicyFSO =3D CreateObject("Scripting.FileSystemObject")
Set objPolicyFile =3D objPolicyFSO.OpenTextFile _
(Policypath, ForReading)
PolicyContents =3D objPolicyFile.ReadAll
objPolicyFile.Close
BasicTextArea.value =3D PolicyContents
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub CheckBox
If Checkbox1.Checked Then
Msgbox "By selecting the (I Agree) checkbox you agree to
the policy listed and it's contents."
Call FolderExist
End If
If Checkbox2.Checked Then
Msgbox "You selected (I Do Not Agree), you will continue to
be prompted to accept this policy" _
& vbcrlf & "as it is a business policy which needs to be accepted."
Call Cancel
End If
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub FolderExist
If PolicyobjFSO.FolderExists(PolicyFolderPath) Then
Set PolicyobjFolder =3D PolicyobjFSO.GetFolder(PolicyFolderPath)
If PolicyobjFSO.FileExists(PolicyTextPath) Then
Set PolicyobjFolder =3D PolicyobjFSO.GetFile(PolicyTextPath)
Call TextFileWrite
Else
Call TextFileCreate
End If
'If PolicyobjFSO.FileExists(PolicyReportingTextPath) Then
' Set PolicyobjFolder =3D
PolicyobjFSO.GetFile(PolicyReportingTextPath)
' Call ReportingTextFileWrite
'Else
' Call ReportingTextFileCreate
'End If
Else
Set PolicyobjFolder =3D PolicyobjFSO.CreateFolder(PolicyFolderPath)
Call TextFileCreate
End If
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub TextFileCreate
Set PolicyTextobjFile =3D PolicyobjFSO.CreateTextFile(PolicyTextPath,
ForWriting, True)
'PolicyTextobjFile.writeline "Created " & Now
PolicyTextobjFile.Close
Set PolicyTextobjFile =3D Nothing
Call TextFileWrite
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub ReportingTextFileCreate
Set PolicyReportingobjFile =3D
PolicyobjFSO.CreateTextFile(PolicyReportingTextPath, ForWriting,
True)
'PolicyReportingobjFile.writeline "Created " & Now
PolicyReportingobjFile.Close
Set PolicyReportingobjFile =3D Nothing
Call ReportingTextFileWrite
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub TextFileWrite
Set PolicyTextobjFile =3D PolicyobjFSO.OpenTextFile (PolicyTextPath,
ForReading)
TextstrWordList =3D PolicyTextobjFile.ReadAll
PolicyTextobjFile.Close
TextstrSearchWord =3D PolicyobjComputer.machinename & vbtab &
PolicyUsername
If InStr(TextstrWordList, TextstrSearchWord) =3D 0 Then
Set PolicyTextobjFile =3D PolicyobjFSO.OpenTextFile
(PolicyTextPath, ForAppending)
PolicyTextobjFile.Writeline PolicyobjComputer.MachineName & vbtab
& PolicyUsername & vbtab & Now
msgbox PolicyobjComputer.MachineName & vbtab & PolicyUsername &
vbtab & Now
PolicyTextobjFile.Close
End If
If PolicyobjFSO.FileExists(PolicyReportingTextPath) Then
Set PolicyobjFolder =3D PolicyobjFSO.GetFile(PolicyReportingTextPath)
Call ReportingTextFileWrite
Else
Call ReportingTextFileCreate
End If
Set PolicyTextobjFile =3D Nothing
Call ReportingTextFileWrite
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub ReportingTextFileWrite
Set PolicyReportingobjFile =3D PolicyobjFSO.OpenTextFile
(PolicyReportingTextPath, ForReading)
ReportingstrWordList =3D PolicyReportingobjFile.ReadAll
PolicyReportingobjFile.Close
ReportingstrSearchWord =3D PolicyobjComputer.machinename & vbtab &
PolicyUsername
If InStr(ReportingstrWordList, ReportingstrSearchWord) =3D 0 Then
Set PolicyReportingobjFile =3D PolicyobjFSO.OpenTextFile
(PolicyReportingTextPath, ForAppending)
PolicyReportingobjFile.WriteLine PolicyobjComputer.machinename &
vbtab & PolicyUsername & vbtab & Now
'msgbox PolicyobjComputer.machinename
PolicyReportingobjFile.Close
End If
Set PolicyReportingobjFile =3D Nothing
Call Cancel
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub Cancel
Set PolicyobjFSO =3D Nothing
Set PolicyobjNetwork =3D Nothing
Set PolicyobjShell =3D Nothing
Set PolicyobjFolder =3D Nothing
Set PolicyobjFolderItem =3D Nothing
Set PolicyobjComputer =3D Nothing
Set PolicyobjShell =3D Nothing
Self.Close
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
</script>
<body TEXT=3D#000000 STYLE=3D"font:14 pt arial; color:Black;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=3D1, StartColorStr=3D'#000000', EndColorStr=3D'#FF9933')">
<Table ALIGN=3DCenter>
<textarea name=3D"BasicTextArea" rows=3D"25" cols=3D"75"></textarea>
</Table>
<TABLE ALIGN=3DRIGHT>
<input type=3D"checkbox" name=3D"Checkbox1"> I Agree<br>
<input type=3D"checkbox" name=3D"Checkbox2"> I Do Not Agree<p>
<input id=3Drunbutton class=3D"button" type=3D"button" value=3D"OK"
name=3D"run_button" onClick=3D"CheckBox">
<input id=3Drunbutton class=3D"button" type=3D"button" value=3D"Cancel"
name=3D "Cancel_Button" onClick=3D"Cancel">
</Table>
</body>