Hi - I am trying to dynamically write vbscript file to c drive. But it will
not execute. I have notice some crap in windiff which suggest that VB has
unusual way of creating a file. Anyway it doesn't work and I was hoping to
use the script to bypass some chunky .NET schedule task code.
Anyone know about creating VBS file from VB.NET?
'--code below
Dim c As Char = """"c
Dim s As String
s = "WScript.Echo " + c + "Hello World" + c
My.Computer.FileSystem.WriteAllText("c:\test.vbs", s, False)
"Jared" <jared@dfidfoe.com> schrieb:
> Hi - I am trying to dynamically write vbscript file to c drive. But it
> will not execute. I have notice some crap in windiff which suggest that
> VB has unusual way of creating a file.
Maybe you are seeing an UTF-8 BOM (Byte Order Mark) at the beginning of the
file.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Herfried K. Wagner [MVP] - 12 Jul 2006 10:33 GMT
Addendum:
> Maybe you are seeing an UTF-8 BOM (Byte Order Mark) at the beginning of
> the file.
The overloaded version of 'WriteAllText' accepts an 'Encoding' object. Pass
in 'System.Text.Encoding.Default' to use the systems ANSI CP.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
WriteAllText is poor method
use StreamWriter ...
Dim writer As IO.StreamWriter = IO.File.CreateText(xPath)
writer.WriteLine(xText)
writer.Close()