Problem with encoding when using setInstallerVariableFromScriptOutput

Answered

Comments

3 comments

  • Avatar
    wojciechka

    Could you let us know which platform is this happening on and what exact command are you running? And what is its default encoding? Some commands print in unicode when printing to console or to a file, but write ANSI when the stdout/stderr is redirected to another program (such as InstallBuilder).

    One option is to redirect output to a file in the .bat file and use <readFile> action, which allows specifying charset encoding.

  • Avatar
    Alberto Esparza

    Hi, It happens in a Windows XP Professional, in a Windows 2008 and in a Windows 7 as far as I have tried it. What I'm doing is calling a .bat file from InstallBuilder and in that .bat file I'm calling a vbs script that does some actions and writes back a result. Is that result what gets messes up. I've builded a simple poc code that shows it

    <project> <shortname>POC</shortname> <fullname>POC</fullname> <version>1.0.0</version> <installerfilename>POC.exe</installerfilename> <defaultlanguage>auto</defaultlanguage> <languageselectionstyle>onlyNativeNames</languageselectionstyle> <initializationactionlist> <writefile> <path>${installer_directory}\poc.vbs</path> <text>WScript.Echo "á é í ó ú ñ"</text> </writefile> <writefile> <path>${installer_directory}\poc.bat</path> <text>@cscript /nologo poc.vbs</text> </writefile> <setinstallervariablefromscriptoutput> <exec>${installer_directory}\poc.bat</exec> <execargs></execargs> <name>prueba</name> </setinstallervariablefromscriptoutput> <showinfo> <text>${prueba}</text> </showinfo> </initializationactionlist> <allowedlanguages>es</allowedlanguages> <createuninstaller>0</createuninstaller> <createwindowsarpentry>0</createwindowsarpentry> <enablerollback>1</enablerollback> <enabletimestamp>1</enabletimestamp> <height>450</height> <outputdirectory>.</outputdirectory> <productdisplayname></productdisplayname> <requireinstallationbyrootuser>1</requireinstallationbyrootuser> <saverelativepaths>1</saverelativepaths> <startmenugroupname></startmenugroupname> <style>custom</style> <uninstallationlogfile>${windows_folder_desktopdirectory}\Uninstall_${product_fullname}_log.txt</uninstallationlogfile> <vendor>POC</vendor> <width>640</width> <windows64bitmode>1</windows64bitmode> <windowsarpregistryprefix></windowsarpregistryprefix> <windowssoftwareregistryprefix></windowssoftwareregistryprefix> </project>

    In the initialization actions I write both the vbs and the bat scripts and then run the bat script with the setInstallerVariableFromScriptOutput action, the script run manually shows the string "á é í ó ú ñ" but when run by InstallBuilder shows a bunch of weird characters.

    Thanks

  • Avatar
    Alberto Esparza

    Finally I got a solution,

    Instead of using the WScript.Echo as we have been using for a while, I'm using Set fso = CreateObject ("Scripting.FileSystemObject") Set stdout = fso.GetStandardStream (1) stdout.WriteLine "á é í ó ú ñ"

    We use a cscript /nologo command to run it and we get the text just fine.

    Thanks anyway for your help and if you see anything that we can improve, I'll be very thankful. Regards.

Please sign in to leave a comment.