我写了这个代码传递参数通过powershell.exe
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[Int32]$BoxAlert,
[Parameter(Mandatory=$true)]
[Int32]$MailAlert
)
)
powershell.exe -WindowStyle Hidden {
if ($timeSpan.Days -ge $BoxAlert) {
drawPopupBox $result
}
if ($timeSpan.Days -ge $MailAlert) {
sendMail $result;
}
}
如何传递$BoxAlert
和$MailAlert
的powershell.exe
脚本块里面?
什么是启动PowerShell.exe内的PowerShell的目的是什么?为什么不调用命令或开始工作? –
由于PowerShell被隐藏窗口调用,我认为这是试图隐藏/抑制控制台输出。如果是这样,使用'Out-Null'或'> $ null 2>&1'将是一个更简单的解决方案。 –
请退后一步,描述您尝试解决的实际问题,而不是您认为的解决方案。这段代码应该在什么情况下运行?为什么你认为你需要'powershell.exe -WindowStyle Hidden'?另外请注意,在你的'Param()'块后面有一个虚假的右括号。 –