DM
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"
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
Note that I am using cscript not wscript to execute the JS file.
Mike
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.
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
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.
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
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")
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")
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")
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