I have two scripts I would like to combine, but the second script can’t begin until a program (Photoshop) is closed. Script one ends by starting a photoshop script with Invoke-Item. Once the Photoshop script is complete PhotoShop closes. The second code archives the raw files with a simple Move-Item. With PowerShell, how can I know when PhotoShop is closed and begin my Move-Item?
I have spent some time researching this to see what documentation there is, but either I am asking my questions poorly or it is an obscure enough I can’t find any leads to begin off of.
# Script One
ii "E:resizerScript.jsx"
#Something to determine when PhotoShop is closed and begin the next bit of code.
# Script Two
Move-Item -path "E:Staged*" -Destination "E:Archived"
I’m very new to coding and what I have is cobbled together from other articles. If anything is too unclear I would be happy to elaborate. Thanks in advance for any help or direction.
2
Answers
Get-Process | Select-Object -Property ProcessName
[UPDATE] if you need to put this inside another script, you need to omit the
param
since this must be the 1st thing in a script. So it would look like:Hope this helps,
Jim
You can use
Wait-Process
,but I recommend using
Start-Process -Wait
to start Photoshop.If you want to set the timeout: