nexxai / CryptoBlocker

A script to deploy File Server Resource Manager and associated scripts to block infected users
GNU General Public License v2.0
200 stars 73 forks source link

SkipList.txt location when run as Scheduled Task #17

Open elgrunt0 opened 7 years ago

elgrunt0 commented 7 years ago

When run as a scheduled task, the script does not make use of the location it's being run from, so it cannot find .\SkipList.txt It defaults to running from C:\Windows\System32 and thus makes a SkipList.txt in that directory instead.

Obvious workaround is to specifically tell Task Scheduler to use the Start in location.

However, could use something like this at line 209:

$invLoc = Split-Path -parent $PSCommandPath
If (Test-Path $invLoc\SkipList.txt)
{
    $Exclusions = Get-Content $invLoc\SkipList.txt | ForEach-Object { $_.Trim() }
    $monitoredExtensions = $monitoredExtensions | Where-Object { $Exclusions -notcontains $_ }

}
nexxai commented 7 years ago

If you want to submit a PR, I'll merge it

JustinCochran commented 7 years ago

What I did was just created a Variable $SkipListLoc = "ENTERLOCATIONHERE" Then I replaced $invLoc with $SkipListLoc in that section.

BloomerzUK commented 7 years ago

I can confirm the above variable addition works perfectly. To make things easier, the script and SkipList are on a UNC path so I only have to update one location. Having a copy on each server would be time consuming for me!

Solaris17 commented 6 years ago

This is really useful. I am attempting to do the same but am unsure of what to modify. Also how are the scheduled tasks being configured? Are you simply modifying the location in the script or also modifying the "Start In" field in the task? Can we get this added to the main script?