Skip to content
⌘ NSIS Forum Archive

Is it possible it run some executable by installer parallel the installer ?

7 posts

Kermit#

Is it possible it run some executable by installer parallel the installer ?

HI.

Here's how I do it:
nsExec::Exec 'powershell -command "& {Do {$PF = ps PROC_1 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name; If ($PF) {ps PROC_2,PROC_3 -ErrorAction SilentlyContinue | kill; Start-Sleep -Seconds 2}} Until (!$PF)}"' 
This command kills PROC_2 and PROC_3 prosesses while PROC_1 process is running

The same PS script in normal condition for example.

Do {
    $PF = ps PROC_1 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name
    If ($PF) {
        ps PROC_2,PROC_3 -ErrorAction SilentlyContinue | kill
        Start-Sleep -Seconds 2
    }
} Until (!$PF) 
Everything works fine, but I need to run it parallel the installer, like a nsExec::ExecNoWait like a start "" powershell ... anallog in cmd.

Is it possible in nsis ?
Or maybe there is another way out ?

Sorry for bad english and hello from Russia 😕
Anders#
I assume you want to hide the console window?

If not you could do
nsExec::Exec '"$sysdir\cmd.exe" /C start "" /MIN "ping" -n 33 localhost'
Pop $0
or if the command is ASCII safe you can do
System::Call `KERNEL32::WinExec(m '"ping" -n 33 localhost', i0)`
Kermit#
Originally Posted by Anders View Post
I assume you want to hide the console window?
Yes, console should be hidden, and this causes problems 🙁

I have seen System::Call a few times at stackoverflow themes, but did not understand how to use it and how it can help me.

For example:
How should I call this PS command
powershell -NoExit -command "& {echo 'THIS IS TEST ECHO'}" 
Using System::Call ?

Thanks for your help.
Anders#
You really need to be able to do some research on your own! If you google WinExec you should be able to figure out what the parameters mean and perhaps figure out that you can just replace my ping example command with something else.

Or do it like this if that makes more sense:
StrCpy $0 '"ping" -n 33 localhost'
System::Call `KERNEL32::WinExec(m r0, i0)`