From c79264f7ef81b8b2e2ee9e8e0025c2df9be86782 Mon Sep 17 00:00:00 2001 From: "Michael H.G. Schmidt" Date: Sat, 28 May 2022 21:37:22 +0200 Subject: [PATCH] bugfix --- tools/logon.cmd | 2 +- tools/set-recyclebin.ps1 | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/logon.cmd b/tools/logon.cmd index eb0fdda..2fa46d8 100644 --- a/tools/logon.cmd +++ b/tools/logon.cmd @@ -85,7 +85,7 @@ if NOT EXIST %LOCALSTATE%\settings.json ( ) rem RECYCLE BIN -powershell -command .\set-recyclebin.ps1 +powershell -command %TOOLS%\set-recyclebin.ps1 if EXIST %STATUSFILE% GOTO END diff --git a/tools/set-recyclebin.ps1 b/tools/set-recyclebin.ps1 index d0a4cfe..8a40436 100644 --- a/tools/set-recyclebin.ps1 +++ b/tools/set-recyclebin.ps1 @@ -10,9 +10,11 @@ foreach ($Drive in $drives) { $Guid=[regex]::Matches($Volume,'{([-0-9A-Fa-f].*?)}') $RegKey="HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\Volume\"+$Guid.value - echo "INFO: setting recyclebin of drive [ $Drive ] to $Size MB" - New-ItemProperty -Path $RegKey -Name MaxCapacity -Value $Size -PropertyType "dword" -Force | Out-Null - New-ItemProperty -Path $RegKey -Name NukeOnDelete -Value 0 -PropertyType "dword" -Force | Out-Null + if (Test-Path $Regkey) { + echo "INFO: setting recyclebin of drive [ $Drive ] to $Size MB" + New-ItemProperty -Path $RegKey -Name MaxCapacity -Value $Size -PropertyType "dword" -Force | Out-Null + New-ItemProperty -Path $RegKey -Name NukeOnDelete -Value 0 -PropertyType "dword" -Force | Out-Null + } }