Disclaimer: I have zero understanding of Powershell. Initially I was going to do this in Java, then decided to do a scheduled task instead, (Executing a PoSh script.)
This is what I have:
$ArmA2OA = Get-Process ArmA2OA - ErrorAction SilentlyContinue
$ChkFile = "C:\Users\Mark27\AppData\Local\ArmA 2 OA\ArmA2OA.rpt"
$FileExists = Test-Path $ChkFile
$currentDate = get-date -uformat "%Y-%m-%d@%H-%M-%S"
if(-Not($ArmA2OA)){
if($FileExists){
move-item "C:\Users\Mark27\AppData\Local\ArmA 2 OA\ArmA2OA.rpt" ("C:\Users\Mark27\Desktop\A2OA\{0:yyyyMMdd}.rpt" -f (get-date))
}
else{break}
}
else{break}
What it's supposed to be doing: If the Process A2OA.exe
isn't running, check to see if a file ArmA2OA.rpt
exists in the directory C:\Users\Mark27\AppData\Local\ArmA 2 OA\
. If that is true, then copy and rename the file using current timestamp and send it to C:\Users\Mark27\Desktop\A2OA
If the file doesn't exist, or the process is running, abort.
I've been through a number of questions similar to this, but haven't found my solution. The directory, and file name I'm looking for will always be the same. (This script will be set to execute every 10-15 minutes.)
No comments:
Post a Comment