Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Foreign characters when using Exec or Run

701 views
Skip to first unread message

DevoMax

unread,
Oct 22, 2009, 2:24:47 AM10/22/09
to
I have several files with characters like "ö" in their filenames. When
I try to use Exec or Run these characters get replaced with weird
series of characters such as "ö" or "├╢". What can I do to fix this?

DM

Pegasus [MVP]

unread,
Oct 22, 2009, 3:56:34 AM10/22/09
to

"DevoMax" <posford...@gmail.com> wrote in message
news:2772b539-706b-4a8d...@d23g2000vbm.googlegroups.com...
I have several files with characters like "�" in their filenames. When

I try to use Exec or Run these characters get replaced with weird
series of characters such as "ö" or "??". What can I do to fix this?

DM

===========

Try to be a little more specific in showing your problem. The following code
works perfectly well - what does your code look like?
Set oWshShell = CreateObject("WScript.Shell")
oWshShell.Run "d:\temp\SchuldundS�hne.bat"


DevoMax

unread,
Oct 23, 2009, 2:02:31 AM10/23/09
to
I created a batch file called "öööö.cmd".

Then, within the JS script I have:

WshShell.Run("öööö.cmd");

The result is an error:

"J:\My Music\_textspeech\test_command.js(9, 1) (null): The system
cannot find the file specified."

Mike

DevoMax

unread,
Oct 23, 2009, 2:07:09 AM10/23/09
to

Note that I am using cscript not wscript to execute the JS file.

Mike

Pegasus [MVP]

unread,
Oct 23, 2009, 4:27:07 AM10/23/09
to

"DevoMax" <posford...@gmail.com> wrote in message
news:746ba97d-8ded-41a5...@m1g2000vbi.googlegroups.com...
I created a batch file called "����.cmd".

Then, within the JS script I have:

WshShell.Run("����.cmd");

The result is an error:

"J:\My Music\_textspeech\test_command.js(9, 1) (null): The system
cannot find the file specified."

Mike

====================

I can think of three possible reasons why your script fails:
a) I quoted a full path for the batch file I wanted to execute. Your script
omits the path elements, which makes it fragile.
b) JScript uses a different method than cscript to process extended
characters. Sorry, can't help you there, I know very little about JScript.
c) Your file name contains Unicode characters. See the post "Download web
page into file not work", posted here three days ago.


DevoMax

unread,
Oct 23, 2009, 8:17:55 AM10/23/09
to
On Oct 23, 4:27 am, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> I can think of three possible reasons why your script fails:
> a) I quoted a full path for the batch file I wanted to execute. Your script
> omits the path elements, which makes it fragile.
> b) JScript uses a different method than cscript to process extended
> characters. Sorry, can't help you there, I know very little about JScript.
> c) Your file name contains Unicode characters. See the post "Download web
> page into file not work", posted here three days ago.

Thanks for taking a look.

a) I tried using a full path without any improvement.
b) Do you mean JScript vs. VBScript?
c) The "ö" character exists in code page 437, or extended ASCII, so it
shouldn't be an issue.

Mike

Pegasus [MVP]

unread,
Oct 23, 2009, 8:31:40 AM10/23/09
to

"DevoMax" <posford...@gmail.com> wrote in message
news:b4cd1695-231b-4b73...@s6g2000vbp.googlegroups.com...

On Oct 23, 4:27 am, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> I can think of three possible reasons why your script fails:
> a) I quoted a full path for the batch file I wanted to execute. Your
> script
> omits the path elements, which makes it fragile.
> b) JScript uses a different method than cscript to process extended
> characters. Sorry, can't help you there, I know very little about JScript.
> c) Your file name contains Unicode characters. See the post "Download web
> page into file not work", posted here three days ago.

Thanks for taking a look.

a) I tried using a full path without any improvement.
b) Do you mean JScript vs. VBScript?

*** Yes. Does the problem persist with VB Script?
c) The "�" character exists in code page 437, or extended ASCII, so it


shouldn't be an issue.

*** Same for "�", which I used my my sample script.

*** I would run these tests:
*** - Change the file name so that it does not contain
*** any extended characters, then repeat the text.
*** - Repeat the test with VB Script.
*** - Try the code I suggested.


DevoMax

unread,
Oct 24, 2009, 10:03:34 PM10/24/09
to
On Oct 23, 8:31 am, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> *** I would run these tests:
> *** - Change the file name so that it does not contain
> *** any extended characters, then repeat the text.

It works if I do this.


> *** - Repeat the test with VB Script.
> *** - Try the code I suggested.

I get more or less the same error.

BTW, here's the command line I'm using:

cscript test_command.vbs


Mike

Pegasus [MVP]

unread,
Oct 25, 2009, 5:51:20 AM10/25/09
to

"DevoMax" <posford...@gmail.com> wrote in message
news:1538735d-f40b-4f16...@e18g2000vbe.googlegroups.com...

cscript test_command.vbs


Mike

=============

Instead of running round in circles, let's nail this one down with you
executing exactly the same script as I am. The script below works and it
generates the expected output in c:\test.txt.

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oBatch = oFSO.CreateTextFile("c:\����.cmd", True)
With oBatch
.WriteLine "@echo off"
.WriteLine "echo %date% %time% >> c:\Test.txt"
.Close
End With
Set oWshScript = CreateObject("WScript.Shell")
oWshScript.Run oWshScript.ExpandEnvironmentStrings _
("%comspec% /c c:\����.cmd")


DevoMax

unread,
Oct 28, 2009, 10:47:45 PM10/28/09
to
On Oct 25, 5:51 am, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> Instead of running round in circles, let's nail this one down with you
> executing exactly the same script as I am. The script below works and it
> generates the expected output in c:\test.txt.
>
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oBatch = oFSO.CreateTextFile("c:\öööö.cmd", True)

> With oBatch
>    .WriteLine "@echo off"
>    .WriteLine "echo %date% %time% >> c:\Test.txt"
>    .Close
> End With
> Set oWshScript = CreateObject("WScript.Shell")
> oWshScript.Run oWshScript.ExpandEnvironmentStrings _
>    ("%comspec% /c c:\öööö.cmd")

The code you provided works. However, a small modification results in
the anomalies I was describing. I.e. run the following code and
compare the name of the outputted text file. When I run the code the
file is named "Test├╢├╢├╢├╢.txt".

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set oBatch = oFSO.CreateTextFile("c:\öööö.cmd", True)


With oBatch
.WriteLine "@echo off"

.WriteLine "echo %date% %time% >> c:\Testöööö.txt"


.Close
End With
Set oWshScript = CreateObject("WScript.Shell")
oWshScript.Run oWshScript.ExpandEnvironmentStrings _

("%comspec% /c c:\öööö.cmd")

Pegasus [MVP]

unread,
Oct 29, 2009, 4:46:10 AM10/29/09
to

"DevoMax" <posford...@gmail.com> wrote in message
news:620de37c-2b93-42fa...@c3g2000yqd.googlegroups.com...

On Oct 25, 5:51 am, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> Instead of running round in circles, let's nail this one down with you
> executing exactly the same script as I am. The script below works and it
> generates the expected output in c:\test.txt.
>
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oBatch = oFSO.CreateTextFile("c:\����.cmd", True)

> With oBatch
> .WriteLine "@echo off"
> .WriteLine "echo %date% %time% >> c:\Test.txt"
> .Close
> End With
> Set oWshScript = CreateObject("WScript.Shell")
> oWshScript.Run oWshScript.ExpandEnvironmentStrings _
> ("%comspec% /c c:\����.cmd")

The code you provided works. However, a small modification results in
the anomalies I was describing. I.e. run the following code and
compare the name of the outputted text file. When I run the code the

file is named "Test????????.txt".

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set oBatch = oFSO.CreateTextFile("c:\����.cmd", True)


With oBatch
.WriteLine "@echo off"

.WriteLine "echo %date% %time% >> c:\Test����.txt"


.Close
End With
Set oWshScript = CreateObject("WScript.Shell")
oWshScript.Run oWshScript.ExpandEnvironmentStrings _

("%comspec% /c c:\����.cmd")

===========

When your VB Script code writes extended ASCII characters such as "�" to a
text file, it appears to use Unicode coding. Instead of using $94 for "�",
it uses $F6. You could now modify your script so that it generates the file
:\����.cmd as a Unicode file in order to make "�"s visible as "�"s. However,
this would not solve your problem since batch files must be written with
ASCII coding, not Unicode.

The modified script below gets around the problem in a different way.
Perhaps there is a more elegant solution but I'm not aware of it.

Oe = Chr(148)


Set oFSO = CreateObject("Scripting.FileSystemObject")

Set oBatch = oFSO.CreateTextFile("c:\����.cmd", True)


With oBatch
.WriteLine "@echo off"

.WriteLine "echo %date% %time% >> c:\Test" _
& String(4, Oe) & ".txt"


.Close
End With
Set oWshScript = CreateObject("WScript.Shell")
oWshScript.Run oWshScript.ExpandEnvironmentStrings _

("%comspec% /c c:\����.cmd")


DevoMax

unread,
Nov 6, 2009, 12:43:01 AM11/6/09
to
Interesting. Thanks.

Recently I switched to another text editor for this purpose, and
simply encoded the source/batch files in DOS 437 format, after which
the problem went away. The program I was using before was Notepad++.
Now I'm using EditPad Lite. I don't know why the first program
couldn't accomplish the same thing since it has an encode-to-ANSI
option.

Anyway, thanks for listening.

Mike

0 new messages