I want to launch a batch file after a file becomes available (after it is copied by a separate robocopy job).
Below is the command I tried.
Do {Write-Host 'Waiting'; Sleep 10;} While ((Test-Path -Path C:\Temp\file.txt) -eq $False) {Start-Process "cmd.exe" "/c C:\Temp\file.bat" -NoNewWindow -Wait}
However, when the while
condition evaluates to False
, Powershell merely prints the statement instead of executing it.