ファイルがロックされているかどうか
参考:https://stackoverflow.com/questions/24992681/powershell-check-if-a-file-is-locked
変数を設定 [$Result; 値:SMPS_ExecSync( "
function Test-FileLock {
param (
[parameter(Mandatory=$true)][string]$Path
)
$oFile = New-Object System.IO.FileInfo $Path;
if ((Test-Path -Path $Path) -eq $false) {
return $false;
}
try {
$oStream = $oFile.Open([System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None);
if ($oStream) {
$oStream.Close();
}
$false;
} catch {
<# file is locked by a process.#>
return $true;
}
}
Test-FileLock 'ファイルのフルパス'
" )]