문제

I'm trying to run a script that copies several files to a group of servers. After words I run another script in another directory to verify they were moved. I can invoke the next folder that I need to go to using:

Invoke-Item c:\scripts\etc

But how can I get it to close a specific comObject? I can close all comObjects using:

(New-Object -comObject Shell.Application).Windows() | foreach-object {$_.quit()}

but this will close all Windows, including IE if open. Is it possible to close it using a specific parameter like LocationName or LocationURL?

Thanks!

도움이 되었습니까?

해결책

Figured it out..

(New-Object -comObject Shell.Application).Windows() | where-object {$_.LocationURL -eq "File:///C:/Scripts/Whatever/Folder/Path"} | foreach-object {$_.quit()}

In case anyone else is dumb like me :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top