带参数的NSIS import powershell脚本 [英] NSIS import powershell script with parameters

查看:352
本文介绍了带参数的NSIS import powershell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个示例程序,它将编写Hello World并创建NSIS文件并执行,对我来说很好用



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





当我执行时,按照写入打印写主机。我的代码在。 ps1文件





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'"

推荐答案

0
Pop
0 Pop


1
DetailPrint'ImportModules打印:
1 DetailPrint '"ImportModules" printed:


1'
SectionEnd
1' SectionEnd





这是我执行时按照写入的方式打印写主机。我的代码在.ps1文件中





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]


这篇关于带参数的NSIS import powershell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆