process - Powershell Delete Locked File But Keep In Memory -


until recently, we've been deploying .exe applications copying them manually destination folder on server. though, file running @ time of deployment (the file called sql server job)--sometimes multiple instances. don't want kill process while it's running. can't wait finish because keeps on being invoked, multiple times concurrently.

as workaround, we've done "cut , paste" via windows explorer on .exe file folder. apparently, moves file (effectively delete) keeps in ram processes using can continue without issues. we'd put new files there called when later program call it.

we've moved automated deploy tool , need automated way of doing this.

stop-process -name someprocess 

in powershell kill process, don't want do.

is there way this? (c# ok.)

thanks,

function moverunningprocess($process,$path) {     if($path.substring($path.length-1,1) -eq "\") {$path=$path.substring(0,$path.length-1)}     $fullpath=$path+"\"+$process     $movetopath=$path + "--backups\$(get-date -f mm-dd-yyyy_hh_mm_ss)"     $moveprocess=$false      $runningprocess=get-wmiobject win32_process -filter "name = '$process'" | select commandline     foreach ($tp in $runningprocess)     {         if ($tp.commandline -ne $null){             $p=$tp.commandline.replace('"','').trim()             if ($p -eq $fullpath) {$moveprocess=$true}         }     }      if ($moveprocess -eq $true)     {         new-item -itemtype directory -force -path $movetopath         move-item -path "$path\*.*" -destination "$movetopath\"     } }  moverunningprocess "processname.exe" "d:\programs\servicefolder" 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -