I believe this is an encoding issue due to the resulting output.
The short of it:
I am trying to make a batch file (meaning .bat) from VB.NET. The output looks fine in a normal text editor, but when executed via the command prompt, it keeps giving me syntax errors to start. I have a hunch it's due to the code that I'm using (or the lack thereof) that is causing the issue.
As you can see below I've even tried using CharCodes, but still to no success. I'm sure it's just an encoding issue, but perhaps some outside help would do
Code:Module Module1 Sub fileop() Dim cd As String Dim fnd As String Dim del As String Dim ms As String Dim inp As String Dim cb As String Dim efnd As String efnd = Chr(32) & Chr(62) & Chr(32) & "output.log" If Form1.CheckBox1.Checked Then cb = " /I " Else cb = "" inp = Form1.TextBox1.Text ms = My.Settings.Setting2 fnd = "@find " del = "@erase " cd = "@cd " Try Dim filePath As String filePath = System.IO.Path.Combine( _ My.Computer.FileSystem.SpecialDirectories.MyDocuments, "test.bat") My.Computer.FileSystem.WriteAllText(filePath, cd & ms & Environment.NewLine & fnd & Chr(34) & inp & Chr(34) & Chr(32) & "test.log" & cb & efnd & Environment.NewLine & del & filePath, False) Catch fileException As Exception Throw fileException End Try End Sub End Module



Reply With Quote
