CryptoBlocker icon indicating copy to clipboard operation
CryptoBlocker copied to clipboard

SkipList.txt location when run as Scheduled Task

Open elgrunt0 opened this issue 8 years ago • 4 comments

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 $_ }

}

elgrunt0 avatar May 23 '17 09:05 elgrunt0

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

nexxai avatar May 23 '17 12:05 nexxai

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

JustinCochran avatar May 23 '17 15:05 JustinCochran

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!

BloomerzUK avatar Jun 26 '17 07:06 BloomerzUK

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?

Solaris17 avatar Aug 05 '17 16:08 Solaris17