Question scripting text file issue

ideprize

Well-known member
Joined
Oct 19, 2011
Messages
97
Programming Experience
10+
Hi All

Writing a simple windows forms to allow me to generate ping test to any IP address. I am generating command files with the ping command in file and they are not executing because the file contents are very strange looking. The leading hex digits in the text file are ff and fe and each character is followed by a 00 hex digit. My research says this has something to do with UTF-8 but what has me scratching my head is why is this the default (wasn't before). I am using the scripting com class and the writeline method to write the command. My highest level candidate for this new default behavior is, however, my upgrade from visual studio 2005 to visual studio 2013. Any insight would be greatly appreciated.

Respectfully,
Ideprize
 
Hi All
As I suspected this problem is a result of my vs upgrade. I have read a number of answers that involved changing settings in VS 2013 - none of them have had any impact on my issue. My issue is not with saving files using vs 2013. My issue is creating .bat files "on the fly" based upon the user input which is an IP address. I can't "resave" the .bat file in notepad++ I am in the middle of execution trying to ping an ip address. My question is how do I force VS 2013 to stop encoding the output from the scripting.writeline method with the UTF-8 encoding and leave it as ANSI encoding! I know this is a function of VS 2013 for I rewrote the program under VS 2005 and the generated bat file is indeed ansi and executable. Surely there must be a way to do this! Thanks in advance.

Respectfully,
Ideprize
 
For what it's worth.
I solved the problem by specifying false for the Unicode argument on the CreateTextFile method.
Respectfully,
Ideprize
 
You can use StreamWriter in .Net, and specify Encoding to use. There is also a Ping class available if you want to avoid command line pings.
 
Thanks for the reply JohnH.
Yes I found the same option with the Scripting class as well. As far as the Ping class goes I have used it in the pass. With a fair amount of work I could use that class to reproduce the ping program's output but time was a factor, so in the name of expedition I went the bat file route instead. I am trying to assemble an extensive log meaning across a long period of time to confirm my suspicions about a "flaky" T1 line. Again thanks for the response.
Respectfully,
Ideprize
 
Back
Top