Skip to content
⌘ NSIS Forum Archive

dosExecute plugin

53 posts

Takhir#
It is possible, may be I'll add new option next weekend (or you can do this earlier 😉 ).
/async should work for now.
Takhir#
I added /detailed option, while installer' Detailed window sync looks not very good with my test app - pauses and jumps when new items appear...
thetw#
Hello, I'm hoping this is the appropriate thread to ask this question...

I am in the process of converting to the unicode NSIS installer and I am using ExecDos. I had to change several other plugins to get it to work, but ExecDos seems to be okay. Can you tell me whether it is Unicode compliant or it is just lucky that no inputs have broken it yet? If it is not Unicode compliant, is there a recommended solution?

Thanks for your help!
Takhir#edited
Current version of ExecDos (July 2007) looks multibyte only. Unfortunately I have not NSIS Unicode installed now, so attached variant is 100% not tested. I just replaced char->TCHAR and added unicode release/debug configurations.
Just found - last string output /towindow and /tofinc may not work if it is not terminated with '\n' - require some code like this is done for /tostack 🙁. And one more - plug-in creates process using Unicode syscall, but I am not sure that catched output from CLI application (redirected to pipes) will be Unicode as well.
Have fun 😉.
NsisUsernew#
Regarding ExecDos

hi all,

I am attaching a python executable with NSIS. The runtime prints of python's windows executable is needed to be outputed on the showdetails field of NSIS's Installation Page. We are using ExecDos dll, plugins to display runtime output of python's windows executable (hello.exe). The code snippet is as follows:

ExecDos::exec /NOUNLOAD /ASYNC /DETAILED /TIMEOUT=10000 "hello.exe"
Pop $0
ExecDos::wait $0

where hello.exe is window's executable of hello.py,
hello.py is:

import os, time, sys
import WConio
print "something is running ....."
sys.stdout.flush()
x = WConio.wherex()
y = WConio.wherey()
WConio.gotoxy(x+50,y-1)
time.sleep(10)
print "ok"
sys.stdout.flush()

"Console window" Output of above hello.exe is:

something is running ...... ok

But when hello exe is used in NSIS, the display looks like this:

something is running .......
ok

My intention is to get the print like as shown for Console window, ie 'ok' on the same line. Can anyone suggest what I am doing wrong? NOTE that when I use the ',' after the first print, the string is buffered even if I do a flush (as sys.stdout.flush()).
Takhir#
gotoxy() sounds like terminal command. First print() sends CR, but after this you move marker back to previous line. None of NSIS plug-ins supports terminal emulation.
NsisUsernew#
Reason of using gotoxy(), is to set the cursor position, as my intention is to print
Something is running........(sleep for 10, then print)..Ok

using below code:

print "Something is running.....",
sys.stdout.flush()
sys.sleep(10)
print "Ok"
sys.stdout.flush()

sys.stdout.flush(), is not working with "comma", it buffers "Something is running....." with "Ok" string and throw result on showdetails window after 10.
Can you suggest the way to make flush to work with ","?
Takhir#
NSIS script allows both " and '. So 'notepad.exe "c:\path to file\file name.txt"' is possible.
Plainjay#
Exec Wait and Logging?

I'm trying to use ExecDos::wait with logging function.. does it not have the same option?

syntax I'm using ExecDos::wait "C:\program.exe" "" "$EXEDIR\test.log"

ExecWait worked fine but I don't think it'll log to a file like I want.
Also tried nsExec::ExecToLog but wasn't getting the result I'm looking for...
Afrow UK#
I have uploaded a new version of the plug-in.

* Added Unicode build (just noticed there was already a Unicode build in this thread but never mind - this version has been tested at least).
* Uses new plug-in API (/NOUNLOAD not necessary with /ASYNC).
* Added /DISABLEFSR switch to disable WOW64 file system redirection on Windows x64 for the internal ExecDos thread (the old version would fail if the executable was in system32).



Stu
HaMsTeYr#
Afrow, I noticed that the log files are encoded in UTF-8. Is there anyway to change that to UTF16-LE?

I'm writing a piece of code at the moment, and I'm trying to read Unicode characters into the stack, via an external file. I'm using the NSIS Unicode build at the moment.

I have tried executing to function instead of out to log, but it seems that only outputting it out to the log keeps the Unicode characters as they are.

I can think of only a few ways to do this, like a FileRead that works for UTF-8 (Using FileRead screws up the characters, and FileReadUTF16LE is no better.)

Another alternative is to stick of course, with FileReadUTF16LE, but the file has to be encoded in UTF-16 LE as well, if not it also becomes a garbled mess.

I know it may seem like asking for much, but would you happen to know any way around this?
Afrow UK#
Someone asked for an x64 build of the plug-in (included as ExecDos64.dll along with the 32-bit ANSI/Unicode builds). Built using latest plug-in API source from SVN. Tested using the NSIS x64 build from https://bitbucket.org/dgolub/nsis64.



Stu
systracer#
Hi, in my tests ExecDos does not support unicode (ASCII is OK) using /tofunc. For example, I am making a cmd file with the following content:
@echo Тестовое сообщение (Test message)
ExecDos::exec '"$SYSDIR\cmd.exe" /c $EXEDIR\Test.cmd' "" "$EXEDIR\Test.txt"
Pop $0
Here Test.txt contains the correct encoding and the message can be read. And in what encoding the cmd file was, the result will be in this (I tried 866 and 1251).

But if I use the following code:
Function Test
Pop $0
FileWrite $R0 '$0' ; or FileWriteUTF16LE /BOM
FunctionEnd

FileOpen $R0 "$EXEDIR\Test.txt" w
GetFunctionAddress $R1 Test
ExecDos::exec /tofunc '"$SYSDIR\cmd.exe" /c $EXEDIR\Test.cmd' "" $R1
Pop $0
FileClose $R0
The result is always bad.

Test.cmd is Windows 866:
1) FileWrite: "******?? ******??? (Test message)"
2) FileWriteUTF16LE /BOM: "メᆬ£¬ᆴᄁᆴᆬ £ᆴᆴᄀ←ᆬᆳᄄᆬ (Test message)"

Test.cmd is Windows 1251:
1) FileWrite: "******?? ******??? (Test message)"
2) FileWriteUTF16LE /BOM: "ᅭ¥￱￲○¬○¥ ￱○○£¥■│¥ (Test message)"

Please help fix the problem.
systracer#
Is this plugin no longer supported? Unfortunately, I couldn't find a better plugin for transferring output to a function, and this one has problems with Unicode.
Anders#
What happens if you just use MessageBox in the Test callback? Is it correct?

What if you do cmd.exe /U /C ...?
systracer#
Anders, thanks for the answer!

Test.cmd in Windows 866, cmd /c + MessageBox = "メᆬ£¬ᆴᄁᆴᆬ £ᆴᆴᄀ←ᆬᆳᄄᆬ (Test message)"
Test.cmd in Windows 866, cmd /u /c + MessageBox = "5AB>2>5 "
Test.cmd in Windows 1251, cmd /c + MessageBox = "ᅭ¥￱￲○¬○¥ ￱○○£¥■│¥ (Test message)"
Test.cmd in Windows 1251, cmd /u /c + MessageBox = "e%EQNBNE "
Test.cmd in Windows UTF8, cmd /c + MessageBox = "￐ᄁ￐ᄉ￑チ￑ツ￐ᄒ￐ᄇ￐ᄒ￐ᄉ ￑チ￐ᄒ￐ᄒ￐ᄆ￑ノ￐ᄉ￐ᄑ￐ᄌ￐ᄉ (Test message)"
Test.cmd in Windows UTF8, cmd /u /c + MessageBox = "h%2h%a%d%d%h%[%h%モ%h%[%h%a% "
Anders#
Testing with cmd is not ideal. I assume you are really going to execute a real application? Does this app write utf-16 to stdout? Or does it write using the active code page and you need the plug-in to convert?
systracer#
I work with cmd files, so I am giving them as an example. There is no problem without /tofunc, which is why I report this problem.
Anders#
The Unicode version of the plug-in is broken as far as I can tell.

Just by looking at the code, the only Unicode handling seems to be that the stdin string is converted from Unicode to CP_ACP and written to the pipe with WriteFile.

There is no handling of the output as far as I can tell.

You can try contacting the author. In the mean time, write it directly to a file instead.

ExecDos::exec '"c:\UnicodeConTest.exe"' "" "$temp\outtmp.txt" ; UTF16-LE passes through untouched
The output when sent to the function or a window/details seems to be converted although I'm not sure where.
vicokoby#
Hi pals,
I'm having trouble with this plugin, when I run
ExecDos::exec /ToStack '"c:\SomeConsoleApp.exe"' ""
the lines are added to the stack but it messes up all the previous items on the stack, I think it may be related to this bug: https://sourceforge.net/p/nsis/bugs/1266/

Iis there any workaround for this?
vicokoby#
Originally Posted by vicokoby View Post
Hi pals,
I'm having trouble with this plugin, when I run the lines are added to the stack but it messes up all the previous items on the stack, I think it may be related to this bug: https://sourceforge.net/p/nsis/bugs/1266/

Iis there any workaround for this?
I found that this issue does not happen if I include two empty strings at the end like this:
ExecDos::exec /ToStack '"c:\SomeConsoleApp.exe"' "" ""