powershell - Running a script when you launch a certain Program -


is possible run script when launching particular file? (access in case) if so, possible using windows task scheduler? also, keep in mind used powershell develop script.

maybe can use wmi event watcher. snippet waits calc.exe launched, runs script adjust priority low. afterwords loops in waiting next instance of calc.exe spawned.

powershell script runs in background changing specific process priority low whenever ran

$prog = get-process -name calc | ?{$_.priorityclass = [system.diagnostics.processpriorityclass]::idle}      while($true)     {         $query = "select * __instancecreationevent within 1 targetinstance isa 'win32_process' , targetinstance.name = 'calc.exe'"             $eventwatcher = new-object management.managementeventwatcher $query              $event = $eventwatcher.waitfornextevent()              $prog = get-process -name calc | ?{$_.priorityclass = [system.diagnostics.processpriorityclass]::idle}     } 

additional info.

http://blogs.technet.com/b/heyscriptingguy/archive/2012/06/08/an-insider-s-guide-to-using-wmi-events-and-powershell.aspx

http://blogs.technet.com/b/heyscriptingguy/archive/2009/01/19/how-can-i-be-notified-when-a-process-begins.aspx

another example.

https://superuser.com/questions/693596/how-to-know-which-service-is-responsible-for-any-exe-running/693601#693601


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -