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.
another example.
Comments
Post a Comment