Old 28th May 2004, 10:46   #1
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
dosExecute plugin

2 parameters - program to start and string to use as stdin for program. Plugin creates child process with redirected i/o (pipes). Works in debug mode now - few Windows popup message boxes appears and console application window is visible - I'll change mode to SH_HIDE and remove messages in next version. Please note following string in execDos.nsi file (see attachment):


execDos::execDos "c:\consApp.exe" "test_login$\ntest_pwd$\n"

Test console appl. included - it printfs header and requests for login and password, then exits. Put it to C:\ for tests or change path in first parameter. Plugin also returns program exit code to stack (if finished, waits max 1 sec, probably something like .r0 required to get it, I am not sure . This may not works with Windows telnet or ftp clients, but with simple console application it was OK.

http://nsis.sourceforge.net/ExecDos_plug-in

Last edited by Afrow UK; 18th January 2011 at 17:47. Reason: Replaced attachement with Wiki page link
Takhir is offline   Reply With Quote
Old 31st May 2004, 07:47   #2
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Project and binaries

Plugin takes 2 strings from stack (application name and stdin text), creates hidden child process with redirected I/O, writes input string parameter to redirected stdin (pipe buffering works fine) and catches stdout. Returns to stack application' exit code.

Project and binaries attached. To test plugin with you application, change file/path and input string parameter in dosExec.nsi, put dosExec.dll to NSIS\Plugin folder and recompile dosExec.nsi script. Run dosExec.exe (uninstall not required). Sample DOS application included – requests for login and password, then exits, you can see how this works if run app. from console window. To use it for plugin test, put consApp.exe to c:\ or change path in script.
Build with MS Visual Studio 6, SP 5. Tested on W98 SE – W2K server.
Please note correct dll and entry point names

dosExec::dosExec "c:\consApp.exe" "test_login$\ntest_pwd$\n"

Last edited by Afrow UK; 18th January 2011 at 17:48. Reason: Removed old attached binary
Takhir is offline   Reply With Quote
Old 12th January 2005, 19:10   #3
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Few versions were published in related threads, but it will be better to continue here Wording and design was improved in current version.
Finally this plug-in based on the same system calls as nsExec, but you can also give 'stdin' string (up to 1024 chars) to running application. In most cases this will be authorization login/password pair.
For example:

execDos::exec "$EXEDIR\consApp.exe" "test_login$\ntest_pwd$\n" "$EXEDIR\execDos.log"

consApp.exe included for test purposes, it sleeps(1 sec) before exit(5), so plug-in text on the top of INSTFILES page becomes visible.

Last edited by Afrow UK; 18th January 2011 at 17:50. Reason: Removed old attached binary
Takhir is offline   Reply With Quote
Old 16th January 2005, 15:04   #4
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Updated to support long strings - now plug-in allocates string buffers according to incoming string_size parameter. This may be 8k for special NSIS build (1024 otherwise). I guess this is also stack string size.

Last edited by Afrow UK; 18th January 2011 at 17:50. Reason: Removed old attached binary
Takhir is offline   Reply With Quote
Old 8th February 2005, 11:17   #5
bdfy
Junior Member
 
Join Date: Feb 2005
Location: Belarus
Posts: 47
Takhir
OK, it works , but just like this NSIS standart command...
Quote:
ExecShell '"$INSTDIR\Res\Campaigns\pbtl.exe" -u resistance.pbo' SW_HIDE
For example
Quote:
execDos::exec '"$INSTDIR\Res\Campaigns\pbtl.exe" -u resistance.pbo'
doesn't match for my script , because I need actions to be sequenced, step-by-step. I have to wait while DOS operation ends. Can you help me ?
I can easily make it in Inno and IMHO NSIS must have this feature.
bdfy is offline   Reply With Quote
Old 8th February 2005, 11:48   #6
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Plug-in waits application to close it's stdout (all done), after this waits for exit_code_process (up to 2 sec) and exits after this only. This is "wait" mode I guess. So once again - is pbtl.exe DOS or "windowed" application? In the last case DOS plug-ins is a wrong way.
Takhir is offline   Reply With Quote
Old 8th February 2005, 12:25   #7
bdfy
Junior Member
 
Join Date: Feb 2005
Location: Belarus
Posts: 47
pbtl.exe is DOS-applicattion and it works about 10 sec in my installer.
bdfy is offline   Reply With Quote
Old 9th February 2005, 14:19   #8
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
During email conversation it was found that the main problem is bad plug-in manual (NSIS tradition ) So I'd like to explain details:
1. Only command_line parameter is mandatory, other parameters (timeout, stdin_string and log_file_name) are optional, may by skipped or ""
execDos::exec command_line [/TIMEOUT=xxx] [stdin_string] [log_file_name]
for example
execDos::exec "$INSTDIR\my_app.exe"
(while stdin_string was main idea of this plug-in – user input emulation)
2. "$EXEDIR\${APP_NAME}.log" log file name in the included script sample require "!define APP_NAME execDos" or something like this (see execDos.nsi )
3. Be very careful with bat files - it's DOS window autoclose mode depends on the user's system settings ("Close On Exit" property), I could reproduce situation with installer hanging. nsExec supports /TIMEOUT parameter, while error "timeout" in such situations may looks like "unsuccessful". May be it is possible to change autoclose parameter for the time when plug-in is running? "cmd.exe /C" works on XP/2K only. Good news - this still works fine with direct call to DOS application (without bat file) .
I added timeout option to ExecDos plug-in, mainly for possible batch file problems, attached.
Takhir is offline   Reply With Quote
Old 9th February 2005, 19:15   #9
bdfy
Junior Member
 
Join Date: Feb 2005
Location: Belarus
Posts: 47
Takhir
The problem isn't solved... check your mail.
bdfy is offline   Reply With Quote
Old 9th February 2005, 20:44   #10
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,333
as far is i know, this bat file will autoclose on all systems:
code:
@echo off
echo hello world
cls

Anders is offline   Reply With Quote
Old 9th February 2005, 23:10   #11
bdfy
Junior Member
 
Join Date: Feb 2005
Location: Belarus
Posts: 47
Anders
the problem is not to close...
the problem is to hide DOS screen while bat file in progress...
bdfy is offline   Reply With Quote
Old 10th February 2005, 07:42   #12
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
This is not plug-in problem
I took bdfy script and did following:
1. Carefully replaced ExecWait calls with ExecDos. After this all black screens dissapeared.
2. Added MessageBoxes showing application exit codes.
3. According to exit codes found and fixed suspicious places in the original code, like this - program extracts file to current SetOutPath dir, but tries to start program from another one
code:

SetOutPath "$INSTDIR\resistance"
File "Files\bat\Resdelete.bat"
ExecWait "$INSTDIR\Resdelete.bat"


Now exit codes of 3 runs are 0, 1 and 1; resistance.pbo file size changed, looks working. Full script sent by email.

2 Anders: XP&2K - no problem, but on Win98 it's a real head pain... In my tests hidden Winoldapps on Win98 remain in Ctrl-Alt-Del list and create problem on next reboot
Takhir is offline   Reply With Quote
Old 10th February 2005, 14:51   #13
bdfy
Junior Member
 
Join Date: Feb 2005
Location: Belarus
Posts: 47
Takhir
Thank you very much (ñ)
All problems are solved , everything works fine - 10x to Takhir.:beer:
bdfy is offline   Reply With Quote
Old 10th February 2005, 15:21   #14
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Sorry, Anders, I re-tested on Win98 and found that your code works! No Oldapps in the tasks list. I searched google but not found this decision.. Thanks
bdfy: do not forget to add 'echo off + cls' to your bat files. Application's output still appears in the log file (if set).
Takhir is offline   Reply With Quote
Old 17th July 2005, 02:12   #15
Guillaume.L
Guest
 
Posts: n/a
How do I install your plugin?
  Reply With Quote
Old 17th July 2005, 06:52   #16
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
1. Download the package http://forums.winamp.com/attachment....postid=1587794 (attached to the post above).
2. Put ExecDos.dll from zip to Program Files\NSIS\Plugins folder on your comp
3. Read included to zip execdos.nsi for usage sample. The simplest command line (no log file and stdin string):

execDos::exec "path\file" "" ""
Pop $0
Takhir is offline   Reply With Quote
Old 17th July 2005, 10:57   #17
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Updated wiki page
Takhir is offline   Reply With Quote
Old 18th July 2005, 22:11   #18
Guillaume.L
Guest
 
Posts: n/a
Is there a way not to make it hide the dos window if there is one?
  Reply With Quote
Old 19th July 2005, 06:45   #19
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Use ExecWait NSIS Instruction (Documentation, 4.9.1.4).
Takhir is offline   Reply With Quote
Old 26th July 2005, 08:41   #20
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
New options (wiki page):
/ASYNC - async application execution. Not waits for process exit, returns control to installer immediately after process launch. New optional 'wait' function to get application exit code (if required). Multithreading worked in my tests, so few DOS application can work at the same time ('exec' returns handle for access to particular process in 'wait' call)
/BRAND - branding text instead of "ExecDos plug-in: exe_name"
Takhir is offline   Reply With Quote
Old 13th June 2006, 19:19   #21
DarkAvenger
Junior Member
 
Join Date: Jun 2006
Posts: 3
Hi Takhir,

is it possible to add an option to start the program as diferent user - pass username and password of new user as parameters. Something like RunAs dll but incorporated in ExecDos.

Thaks in advanced
DarkAvenger is offline   Reply With Quote
Old 14th June 2006, 18:18   #22
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
It is possible, but most of used API calls marked in MSDN as NT (XP?) compatible only, so we can lose Win9x this case.
Takhir is offline   Reply With Quote
Old 14th June 2006, 19:27   #23
DarkAvenger
Junior Member
 
Join Date: Jun 2006
Posts: 3
Takhir,

thank you for your fast reply... Windows NT/2000/XP/2k3/Vista is ok with me... You can add a new function to the dll with run as functionality without lose existing one that support 9x OS.
Looking forward for the new version of ExecDos with RunAs ...

Thanks in advanced

Last edited by DarkAvenger; 14th June 2006 at 20:03.
DarkAvenger is offline   Reply With Quote
Old 22nd June 2006, 17:45   #24
dmccordjr
Junior Member
 
Join Date: Jun 2006
Posts: 3
Smile Feature Request: Allow a value for no Timeout

Please, I humbly request you to Permit a "No" Timeout value for /TIMEOUT or a flag for example

/TIMEOUT=-1 or /NOTIMEOUT Whatever works best for you.

I would like to use this command to Launch Applications. Mainly Java Applications. The Applications Run Indefinitely.

So I need a way to Turn off the time out. The man reason I want to use your tool is the Log to file and the Async.

We tend to use NSIS as a Compiled Batch File for little utilities.
dmccordjr is offline   Reply With Quote
Old 22nd June 2006, 19:31   #25
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
If not set, timeout is 0xffffff ms = 4 hours. You can define it as 0xffffffff this will be 256 times more. Is this enough?
Takhir is offline   Reply With Quote
Old 22nd June 2006, 20:29   #26
dmccordjr
Junior Member
 
Join Date: Jun 2006
Posts: 3
Takir

Wow, well that's 42 days, approximately. LOL! That will work. Not quite the same a never. But definitely long enough, I certainly hope our users open and close the app at least once in 1024 hours.

Thanx for the quick response.
dmccordjr is offline   Reply With Quote
Old 23rd June 2006, 06:40   #27
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
May be you need no-wait application launch, this case use ExecShell (NSIS command) or WinExec (via System plug-in). Both support SW_HIDE parameter and not waits a process exit (and allows installer to finish).
Takhir is offline   Reply With Quote
Old 11th December 2006, 14:15   #28
Clammerz
Junior Member
 
Join Date: Apr 2006
Posts: 24
Sorry if I'm bumping the wrong thread, but this was the thread linked to on the Wiki page.

How do you utilize the /TOSTACK option?
The Wiki page is kinda poorly documented on this feature.
Clammerz is offline   Reply With Quote
Old 11th December 2006, 15:15   #29
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Plug-in pushes to stack as many (not empty) lines as it gets from app's stdout basing on '\n' delimiter (\r char just skipped). Long lines will be truncated on the NSIS line limit (1024-1 for common build). If log defined data go to file as well.
Takhir is offline   Reply With Quote
Old 11th December 2006, 16:39   #30
Clammerz
Junior Member
 
Join Date: Apr 2006
Posts: 24
Oh, thank you.
I was hoping it would work somewhat similar to a 'live output' that the logfile option does.
Would make it easier to handle live output internally by NSIS rather than reading from the logfile.

I was wondering... Since you have already successfully redirected live output to a logfile, is it possible for you to redirect it to the details box?

I have a external application that needs to run during install. It outputs it's progress as dots:
"............" and so on, untill it reaches:
".............................. DONE."

ExecToLog is unable to do it. It was discussed allot in this thread:
http://forums.winamp.com/showthread....hreadid=126972

But no solution was found.

If it can't be done, I guess I can resort to /ASYNC, and have a loop reading from the file every 1/2 a second or so..

Thanks for your help thus far.
Clammerz is offline   Reply With Quote
Old 11th December 2006, 18:56   #31
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
It is possible, may be I'll add new option next weekend (or you can do this earlier ).
/async should work for now.
Takhir is offline   Reply With Quote
Old 13th December 2006, 10:00   #32
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
I added /detailed option, while installer' Detailed window sync looks not very good with my test app - pauses and jumps when new items appear...
Takhir is offline   Reply With Quote
Old 4th August 2009, 00:02   #33
thetw
Junior Member
 
Join Date: Apr 2004
Posts: 4
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!
thetw is offline   Reply With Quote
Old 4th August 2009, 18:09   #34
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
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 .

Last edited by Afrow UK; 18th January 2011 at 17:54. Reason: Removed old attached binary
Takhir is offline   Reply With Quote
Old 16th November 2009, 09:20   #35
NsisUsernew
Junior Member
 
Join Date: Nov 2009
Posts: 3
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()).
NsisUsernew is offline   Reply With Quote
Old 17th November 2009, 06:55   #36
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
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.
Takhir is offline   Reply With Quote
Old 18th November 2009, 16:55   #37
NsisUsernew
Junior Member
 
Join Date: Nov 2009
Posts: 3
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 ","?
NsisUsernew is offline   Reply With Quote
Old 17th March 2010, 00:44   #38
Genjuro
Junior Member
 
Join Date: Mar 2010
Posts: 4
If the parameters of the program has "", what i do?
Genjuro is offline   Reply With Quote
Old 17th March 2010, 13:52   #39
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
NSIS script allows both " and '. So 'notepad.exe "c:\path to file\file name.txt"' is possible.
Takhir is offline   Reply With Quote
Old 28th July 2010, 21:53   #40
Plainjay
Junior Member
 
Join Date: Jun 2010
Posts: 9
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...
Plainjay is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump