我编写了一个示例程序,它将编写Hello World
并创建NSIS
文件,并执行该文件对我来说很好
我的.nsi
脚本如下
!include "x64.nsh"
Name "nsExec Test"
OutFile "nsExecTest.exe"
#ShowInstDetails show
Section "Output to variable"
nsExec::ExecToStack 'powershell.exe "& "Import-Module C:\PowerShell\Hello.psm1"'
Pop $0
Pop $1
DetailPrint '"ImportModules" printed: $1'
SectionEnd
当我执行时,按照写入的方式打印写入主机
我在.psm1
档案中的代码
# Filename: Hello.psm1
Write-Host
Write-Host 'Hello World!'
Write-Host "Good-bye World! `n"
# end of script
现在我试图用参数实现相同的功能,有人可以帮助我
# Filename: TestParameter.psm1
function TestParam([string] $TestParam)
{
Write-Host
Write-Host '$TestParam'
Write-Host "Good-bye $TestParam! `n"
}
# end of script
答案 0 :(得分:0)
而不是模块,如何使用普通脚本?
在C:\PowerShell\script1.ps1
:
param([string]$TestParam)
Write-Host
Write-Host '$TestParam'
Write-Host "Good-bye $TestParam! `n"
然后在nsi
:
nsExec::ExecToStack 'powershell.exe "& "C:\PowerShell\script.ps1 -TestParam myString"'