Chaitanya

Chaitanya

  • NA
  • 58
  • 55.7k

NSIS import PowerShell script with parameters

Aug 31 2016 8:27 AM

I have written a sample program that will write Hello World and created NSIS file and executed which works fine for me

My .nsi script goes as follows

  1. !include "x64.nsh"  
  2.   
  3. Name "nsExec Test"  
  4. OutFile "nsExecTest.exe"  
  5. #ShowInstDetails show  
  6.   
  7. Section "Output to variable"  
  8. nsExec::ExecToStack 'powershell.exe "& "Import-Module C:\PowerShell\Hello.ps1"'  
  9. Pop $0  
  10. Pop $1  
  11. DetailPrint '"ImportModules" printed: $1'  
  12. SectionEnd  

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

 
  1. # Filename: Hello.psm1  
  2. Write-Host  
  3. Write-Host 'Hello World!'  
  4. Write-Host "Good-bye World! `n"  
  5. # end of script  
Now I am trying to achieve the same with parameters, can some one help me
 
  1. # Filename: TestParameter.ps1  
  2. function TestParam([string] $TestParam)  
  3. {  
  4.     Write-Host  
  5.     Write-Host '$TestParam'  
  6.     Write-Host "Good-bye $TestParam! `n"  
  7. }  
  8. # end of script  
 

Answers (1)