I have a VB script who starts Diskpart using WshShell.Exec.

Commands are sent to diskpart via WshScriptExec.Stdin and the output from diskpartis read from
WshScriptExec.Stdout.

All work just fine in an English-US environment. However under a french or italian environments, the
accented characters like "é à è ..." are translated to some other characters within the EN-US
character set when the script reads the output of diskpart from stdout.

Is there a way to configure VBScript to create Unicode based streams (stdin/stdout) when creating
the process to execute?

Alternatively, is there a known workaround to this design limitation of VBScript?

Regards,

Gaetan

Re: WshScriptExec mangle stdout characters by Walter

Walter
Fri Jul 14 03:01:18 CDT 2006

I think that the limitation is either in diskpart.exe or the command
processor, not in VBScript. No guarantees, but try invoking diskpart this
way:

cmd /u/c diskpart

The /u switch tells cmd.exe to output to stdin/stdout/stderr using unicode.
For some strange reason, it must be the first switch listed, at least on my
system.

"Gaetan Simard" <gaetan.simard@eds.com> wrote in message
news:lpddb21m602dn9t5shg4actcs1vjrvnbtp@4ax.com...
>
> I have a VB script who starts Diskpart using WshShell.Exec.
>
> Commands are sent to diskpart via WshScriptExec.Stdin and the output from
> diskpartis read from
> WshScriptExec.Stdout.
>
> All work just fine in an English-US environment. However under a french or
> italian environments, the
> accented characters like "é à è ..." are translated to some other
> characters within the EN-US
> character set when the script reads the output of diskpart from stdout.
>
> Is there a way to configure VBScript to create Unicode based streams
> (stdin/stdout) when creating
> the process to execute?
>
> Alternatively, is there a known workaround to this design limitation of
> VBScript?
>
> Regards,
>
> Gaetan



Re: WshScriptExec mangle stdout characters by Gaetan

Gaetan
Fri Jul 14 10:54:32 CDT 2006

Unfortunately, that did not fix the characters corruption. What I think is happenning is that the
strings in the program I'm running (diskpart.exe) are stored in Unicode format (I use a hex editor
to browse the file) but they display differently whether diskpart is run from a command prompt or
through a VBScript WshScriptExec object.

When I run diskpart directly from the command line, the OS properly format the strings using the
codepage in use in the command prompt. Meaning that characters like "é" when produced by diskpart
shows like "é".

However, when I run diskpart from a VBScript using the WshScriptExec object (WshShell.Exec()), the
characters appear differently on the STDOUT stream. A "é" shows as a " ' ".

For instance, when I run cscript.exe from command prompt, the cscript logo shows normally. But when
the script itself calls cscript and write to the console the output of the called cscript.exe, the
output looks different;

C:\temp>cscript dp.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. Tous droits réservés.

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. Tous droits r'serv's.

Isn't internationalization great or what :-)