Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have written a sample program that will write Hello World and created NSIS file and executed which works fine for me

!include "x64.nsh"  
  
Name "nsExec Test"  
OutFile "nsExecTest.exe"  
#ShowInstDetails show  
  
Section "Output to variable"  
nsExec::ExecToStack 'powershell.exe "& "Import-Module C:\PowerShell\Hello.ps1"'  
Pop $0  
Pop $1  
DetailPrint '"ImportModules" printed: $1'  
SectionEnd


Which is printing the write host as per written when I executed it. My code in .ps1 file

# Filename: Hello.psm1  
Write-Host  
Write-Host 'Hello World!'  
Write-Host "Good-bye World! `n"  
# end of script 


Now I am trying to achieve the same with parameters, can some one help me

# Filename: Hello.ps1  
function TestParam([string] $TestParam)  
{  
    Write-Host  
    Write-Host '$TestParam'  
    Write-Host "Good-bye $TestParam! `n"  
}  
# end of script  


What I have tried:

nsExec::ExecWait  "powershell -File C:\Dorababu\PowerShell\testparam1.ps1 -param1 'Hello'"
Posted
Updated 16-Sep-16 0:52am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900