Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Best practice for monitoring processes with low memory/cpu usage

$
0
0

Hello,

I have a win 7 box running as a kiosk. Hardware could be an issue since it is really old and won't be changed. There's only one application that is running: IE. My aim is to re-launch IE whenever it is closed. I have written this little script to do so:

$ErrorActionPreference = "Stop"

while ($true) {

    try {
        Get-Process iexplore | out-null
    }
    catch {  
        Start-Process iexplore.exe
    }
    finally {
        sleep -Seconds 5
    }
}


My question is should I rather have a scheduled task that would run every x seconds in order to check IE process and relaunch it?

Or should I keep with a script as service even if it is not best practice? If yes, should I use: [gc]::Collect() in the catch block in order to free up memory or am I totally wrong from the beginning?

Thanks a lot for reading and helping!






Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>