Old 18th January 2022, 11:23   #1
aNoNameMoose
Junior Member
 
Join Date: Jan 2022
Posts: 2
Need help with ExecWait and/or ExecShell

Hey!

I'm creating an installer and as we finish copying files, prompt install for some prerequisites, we want to execute a couple of powershell scripts (.ps1 extension)
One is a single string replacement script, which works fine with ExecWait.
ExecWait 'powershell.exe -file "$INSTDIR\replace.ps1" "$ConnStr" "$INSTDIR"'

So that works very nicely.

ExecShell "" "$INSTDIR\replace.ps1" '/param1="$ConnStr" /param2="$INSTDIR"' SW_SHOWNORMAL

I tried this a multitude of ways and parameters never get passed, this is just the latest.
The first one I have tried:
ExecShell "" "$INSTDIR\replace.ps1" '"$ConnStr" "$INSTDIR"' SW_SHOWNORMAL

I have tried with "open", does the same as the empty one, with "runas" it doesn't even execute.
How am I supposed to pass multiple parameters with ExecShell?
Bonus question: Does it run 32bit or 64bit powershell? Does it run the "default"? whatever that is

I've googled for a couple hours now and checked docs of course but it didn't help out enough
aNoNameMoose is offline   Reply With Quote
Old 18th January 2022, 15:08   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,502
Why do you want to use ExecShell? The default handler for a .ps1 file might be a text editor! ExecShell does usually not support parameters for things that are not .exe files.

You can also do
PHP Code:
nsExec::Exec 'powershell -inputformat none -ExecutionPolicy RemoteSigned -File "$InstDir\myFile.ps1"'
Pop $R0 ; exit code 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 19th January 2022, 08:30   #3
aNoNameMoose
Junior Member
 
Join Date: Jan 2022
Posts: 2
I see, we really need to use the parameters.
We went back to ExecWait, and it seems the problem was actually 64bit redirection and turning it off solved our problems for now.
Thank you for the reply!
aNoNameMoose is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
commandline, execshell, execwait, powershell

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