Strange happenings with Process

  • Thread starter Thread starter Lloyd Sheen
  • Start date Start date
L

Lloyd Sheen

I am trying to run a batch file using Process (it uses cmd.exe).

I am in testing just attempting to do a dir command right now.

When I put the following line in the .bat file

dir

I get back the following:
'´??dir' is not recognized as an internal or external command,
operable program or batch file.

I get the same if I open a command window. I have opened the file in a hex
editor and those characters do not exist. I have changed the name to
filename.cmd and the same happens. This makes no sense.

Any ideas?

Thanks
LS
 
Lloyd Sheen said:
I am trying to run a batch file using Process (it uses cmd.exe).

I am in testing just attempting to do a dir command right now.

When I put the following line in the .bat file

dir

I get back the following:
'´??dir' is not recognized as an internal or external command,
operable program or batch file.

I get the same if I open a command window. I have opened the file in a
hex editor and those characters do not exist. I have changed the name to
filename.cmd and the same happens. This makes no sense.

Any ideas?

Thanks
LS

The problem as I found is with the encoding. If you create a text file in
VS 2008 you get UTF-8 encoding it seems. Is there a way to create/save text
files with ANSI encoding. Properties does not show this, there is nothing
on the save or save/as that allows this. Notepad is better in this case it
seems.

LS
 
The problem as I found is with the encoding.  If you create a text filein
VS 2008 you get UTF-8 encoding it seems.  Is there a way to create/savetext
files with ANSI encoding.

To save a text file using desired encoding option, StreamWriter class
has a encoding parameter in its constructor that allows you to pass
desired encoding as "default" for ANSI encoding. For example use this
for that purpose:

Using writer As New System.IO.StreamWriter _
("c:\file.txt", True, System.Text.Encoding.Default)
' Do the stuff
End Using

http://msdn.microsoft.com/en-us/library/system.text.encoding.default.aspx

HTH,

Onur Güzel
 
The problem as I found is with the encoding. If you create a text file in
VS 2008 you get UTF-8 encoding it seems. Is there a way to create/save
text
files with ANSI encoding.

To save a text file using desired encoding option, StreamWriter class
has a encoding parameter in its constructor that allows you to pass
desired encoding as "default" for ANSI encoding. For example use this
for that purpose:

Using writer As New System.IO.StreamWriter _
("c:\file.txt", True, System.Text.Encoding.Default)
' Do the stuff
End Using

http://msdn.microsoft.com/en-us/library/system.text.encoding.default.aspx

HTH,

Onur Güzel


Thanks but I am asking about VS2008. I created the .bat file from the IDE
and it stores as UTF-8 with no provision I can see to change the encoding.
Once the file is created it retains the encoding so I can create the file
with notepad which allows the user to state the encoding.

Thanks
LS
 
To save a text file using desired encoding option, StreamWriter class
has a encoding parameter in its constructor that allows you to pass
desired encoding as "default" for ANSI encoding. For example use this
for that purpose:

Using writer As New System.IO.StreamWriter _
("c:\file.txt", True, System.Text.Encoding.Default)
' Do the stuff
End Using

http://msdn.microsoft.com/en-us/library/system.text.encoding.default....

HTH,

Onur Güzel

Thanks but I am asking about VS2008.  I created the .bat file from the IDE
and it stores as UTF-8 with no provision I can see to change the encoding..
Once the file is created it retains the encoding so I can create the file
with notepad which allows the user to state the encoding.

Thanks
LS

OK, Sorry that i don't have VS 2008 right now, however i can give a
clue for VB 2005 (mine is Express edition currently, and maybe the
steps may be similar for VS 2008). First insert a new text file
through "add new item" or if it exists already. Then follow File menu -
Save textfile1.txt As... -> Then...On "Save file As" dialog, there
is a little, tiny down-oriented arrow on Save button. Click on it and
choose "Save with encoding...". Then define desired encoding.

Hope those are similar in 2008,

Onur Güzel
 
OK, Sorry that i don't have VS 2008 right now, however i can give a
clue for VB 2005 (mine is Express edition currently, and maybe the
steps may be similar for VS 2008). First insert a new text file
through "add new item" or if it exists already. Then follow File menu -> Save textfile1.txt As... -> Then...On "Save file As" dialog, there

is a little, tiny down-oriented arrow on Save button. Click on it and
choose "Save with encoding...". Then define desired encoding.

Hope those are similar in 2008,

Onur Güzel

And it seems that article on MSDN should support what i've mentioned:
http://msdn.microsoft.com/en-us/library/dxfdkfke.aspx

Onur Güzel
 
Back
Top