Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 27th April 2016, 19:38   #1
Kermit
Junior Member
 
Join Date: Apr 2016
Posts: 3
Is it possible it run some executable by installer parallel the installer ?

HI.

Here's how I do it:
PHP Code:
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.

PHP Code:
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
Kermit is offline   Reply With Quote
Old 27th April 2016, 19:59   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,191
I assume you want to hide the console window?

If not you could do
Quote:
nsExec::Exec '"$sysdir\cmd.exe" /C start "" /MIN "ping" -n 33 localhost'
Pop $0
or if the command is ASCII safe you can do
Quote:
System::Call `KERNEL32::WinExec(m '"ping" -n 33 localhost', i0)`

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 27th April 2016, 20:32   #3
Kermit
Junior Member
 
Join Date: Apr 2016
Posts: 3
Quote:
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
PHP Code:
powershell -NoExit -command "& {echo 'THIS IS TEST ECHO'}" 
Using System::Call ?

Thanks for your help.
Kermit is offline   Reply With Quote
Old 27th April 2016, 22:49   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,191
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:
Quote:
StrCpy $0 '"ping" -n 33 localhost'
System::Call `KERNEL32::WinExec(m r0, i0)`

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 27th April 2016, 23:22   #5
Kermit
Junior Member
 
Join Date: Apr 2016
Posts: 3
I think I got it. Finaly
Thank you very much. This works for me

Click image for larger version

Name:	shot.PNG
Views:	131
Size:	34.3 KB
ID:	52371
Kermit is offline   Reply With Quote
Old 28th April 2016, 01:17   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,191
I also forgot about ExecShell, it accepts SW_HIDE as the last parameter...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 6th May 2016, 12:21   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
ExecDos has /async and ::wait.

Stu
Afrow UK 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