-
Notifications
You must be signed in to change notification settings - Fork 2
/
vcn-folder-watch.ps1
24 lines (21 loc) · 1.08 KB
/
vcn-folder-watch.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
### Set vcn binary path - please download vcn here: https://github.com/vchain-us/vcn/releases/latest
$vcnpath = """$env:programfiles\codenotary\vcn.exe"""
### Set target directory and file types to watch for changes and if you want to include subdirectories
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = "C:\Users\user\Documents\Notarize"
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $true
### Define notarization when files are detected
$action = { $path = $Event.SourceEventArgs.FullPath
$changeType = $Event.SourceEventArgs.ChangeType
$param = " n " + """$Path""" + " --attr PSEvent=True"
$command = $vcnpath + "$param"
iex "& $command"
$logline = "Notarized $(Get-Date), $changeType, $path"
write-host $logline
Add-content ($watcher.Path + "\codenotary.log") -value $logline
}
### DECIDE WHICH EVENTS SHOULD BE WATCHED
Register-ObjectEvent $watcher "Created" -Action $action
# Register-ObjectEvent $watcher "Renamed" -Action $action
while ($true) {sleep 5}