I have an infinity loop process. I will check a file, once the file exist, then I process it. Is it possible if I found the file, then I lock it, so people will not able to open or modify the file until the process finish.
do{
if(Test-Path -Path ".\Data.txt")
{
$file = Get-content -Path ".\Data.txt"
## do some process ##
#
#
#
#
#modify the file extension to .don once
# process
#
#FINISHED (the process will finished once the extension modified)
}
}
while(1)
Anyone can give idea please. Thank you.