Search code examples
vbscriptparametersargumentsiconv

Running iconv.exe with vbscript in Windows


When triyng to run iconv.exe under windows with the VBScript, the arguments don't go to executable.

Set SHL = CreateObject("WScript.Shell")

SHL.Run """iconv.exe"" -f utf-16 -t utf-8 in.txt > out.txt" 

I think it's error with quotes but can't find the right way.


Solution

  • .Run starts a process, not a shell. You need a shell for shell's features like re-direction. So:

    Dim SHL  : Set SHL = CreateObject("WScript.Shell")
    Dim iRet : iRet    = SHL.Run("%comspec% /c ""iconv.exe"" -f utf-16 -t utf-8 in.txt > out.txt", 0, True)