Archive: nsExec


nsExec
Documentation says :
nsExec will execute command-line based programs and capture the output without opening a dos box.
This is really a nice feature.
Question is, does it behave like ExecWait and waits till the program terminates or there is error executing the program?
Do I need to specify any timeout option to make it behave like ExecWait()
Thanks


Yes, it waits.


Thanks, Kichik. A follow up question: As part of the installation, I need to stop, remove, uninstall and reinstall one or more Windows services on Windows 2000 and Windows 2003 server platforms.
Currently I am using ExecWait 'net start' etc. If the service can not be stopped (and it could happens in production environment) and goes into error state, is ExecWait() going to hang? Would nsExec with timeout parameters be a better option? With nsExec I can retry and eventually pop up a dialog box indicating error -- What do you think?
I have seen some plugins as well which use C APIs to talk to ServiceControl manager? Is this approach any better than 'net start' etc commands when it comes to handling errors -- That's the most important thing for me.
Thanks for your help.


The plug-ins are built especially for handling services, so I'd imagine they have better error handling then ExecWait or nsExec for this specific case. Besides, using API is always better than a command line utility which may not have the same interface in future versions, on different languages or might not even exist in older versions of Windows.


Would ExecWait() hang, though or it recovers gracefully? Thanks.


It'll wait until the process it executed returns. If the process hangs, it'll hang.


I guess then, I have two choices to recover gracefully from errors:
Use nsExec with timeout, parse its output and retry or show error dialog.
Go for the plugin approach.