现在我有一个powershell脚本,它会在测试路径之后启动Lync,然后启动Skype for business以查看它是否存在。我正在尝试将下面的内容添加到更大的if语句中,因此它将运行lync部分,然后仅在lync不存在时才运行office communicationator部分。我尝试了几种不同的方法并且失败了。有人可以帮忙吗?
if (Test-Path 'C:\Program Files (x86)\Microsoft Office\office15\lync.exe'){
Start-Process 'C:\Program Files (x86)\Microsoft Office\office15\lync.exe'
} Else {
write-host "Lync is not installed"}
if (Test-Path 'C:\Program Files (x86)\Microsoft Office Communicator'){
Start-Process 'C:\Program Files (x86)\Microsoft Office Communicator\communicator.exe'
} Else {
write-host "Communicator is not installed"}
答案 0 :(得分:0)
您需要将第二个IF嵌套在第一个的ELSE中,如下所示:
if (Test-Path 'C:\Program Files (x86)\Microsoft Office\office15\lync.exe')
{
Start-Process 'C:\Program Files (x86)\Microsoft Office\office15\lync.exe'
}
Else
{
write-host "Lync is not installed"
if (Test-Path 'C:\Program Files (x86)\Microsoft Office Communicator')
{
Start-Process 'C:\Program Files (x86)\Microsoft Office Communicator\communicator.exe'
}
Else
{
write-host "Communicator is not installed"}
}
}