Reputation: 101
Is it possible to run a Script when launching a particular file? (Access in this case) If so, is it possible using the windows task scheduler? Also, keep in mind I used powershell to develop the script.
Upvotes: 0
Views: 2502
Reputation: 7046
Maybe you can use a WMI event watcher. This snippet waits for calc.exe to be launched, then runs a script to adjust the priority to low. Afterwords it loops in waiting for the next instance of calc.exe to be spawned.
$prog = Get-Process -Name calc | ?{$_.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::Idle}
while($true)
{
$Query = "select * from __instanceCreationEvent within 1 where targetInstance isa 'win32_Process' AND 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.
Upvotes: 1