From bb07bc3512f363d591467d40294c2c6fd422d49c Mon Sep 17 00:00:00 2001 From: Christian Pohle Date: Sat, 29 Oct 2022 19:37:21 +0200 Subject: [PATCH] . --- .../Windows/CopyGoogleChromeBookmarks.vbs | 65 +++++++++++++++++++ Microsoft/Windows/DeleteMachineCert.cmd | 15 +++++ 2 files changed, 80 insertions(+) create mode 100755 Microsoft/Windows/CopyGoogleChromeBookmarks.vbs create mode 100644 Microsoft/Windows/DeleteMachineCert.cmd diff --git a/Microsoft/Windows/CopyGoogleChromeBookmarks.vbs b/Microsoft/Windows/CopyGoogleChromeBookmarks.vbs new file mode 100755 index 0000000..4a74caf --- /dev/null +++ b/Microsoft/Windows/CopyGoogleChromeBookmarks.vbs @@ -0,0 +1,65 @@ +' CopyGoogleChromeBookmarks.vbs - Copy Bookmarks File of Google Chrome to HomeDir +' and retain the last 14 Files (by Creation Date) + +' v1.0 - 29.10.2022 - Initial Release + +' WSHShell + Dim objWSH + Set objWSH = CreateObject("WScript.Shell") + +' Define Variables + strProfileFolder = objWSH.ExpandEnvironmentStrings("%LOCALAPPDATA%") & "\Google\Chrome\User Data\Default\" + strBackupBaseFolder = "H:\Backup\" + strBackupFolder = "H:\Backup\Chrome\" + strBackupFile = "BOOKMARKS" + intMaxFiles = 14 + +' File System Object + Dim objFSO + Set objFSO = CreateObject("Scripting.FileSystemObject") + +' Define actual Backup Folder + strActualBackupFile = strBackupFile & "_" & fncDateTimeString(now()) + +' Check, whether Backup Base Folder exists + If Not objFSO.FolderExists(strBackupBaseFolder) Then + objFSO.CreateFolder strBackupBaseFolder + End If + +' Check, whether Backup Folder exists + If Not objFSO.FolderExists(strBackupFolder) Then + objFSO.CreateFolder strBackupFolder + End If + +' Copy File + objFSO.CopyFile strProfileFolder & strBackupFile, strBackupFolder & strActualBackupFile + +' Only run if we actually have more than 14 files... + Dim objFolder + Set objFolder = objFSO.GetFolder(strBackupFolder) + If objFolder.Files.Count > intMaxFiles Then + +' Create an array to the hold the dates of each file in this folder... + ReDim aryFiles(objFolder.Files.Count - 1) + +' Read all Files into an Array + i = 0 + For Each oFile In objFolder.Files + aryFiles(i) = oFile.DateCreated + i = i + 1 + Next + +' Get the 14th most-recent date... + dtmCutOff = aryFiles(i-intMaxFiles) + +' Iterate the files once more and delete any files older than our cut-off... + For Each oFile In objFolder.Files + If oFile.DateCreated < dtmCutOff Then oFile.Delete + Next + + End If ' objFolder.Files.Count > intMaxFiles + + Function fncDateTimeString(datDate) +' Format the Date as yyyymmdd + fncDateTimeString = Year(datDate)& right("0" & Month(datDate),2) & right("0" & Day(datDate),2) & right("0" & Hour(datDate),2) & right("0" & Minute(datDate),2) & right("0" & Second(datDate),2) + End Function diff --git a/Microsoft/Windows/DeleteMachineCert.cmd b/Microsoft/Windows/DeleteMachineCert.cmd new file mode 100644 index 0000000..2379160 --- /dev/null +++ b/Microsoft/Windows/DeleteMachineCert.cmd @@ -0,0 +1,15 @@ +@echo off +rem : Delete Machine Cert - Remove Certificate Named like the Computer +rem : Must be run as "Local System" by Software Management +rem : © 2022 Pohle ICT AG + +rem : v1 - 23.07.2022 - Initial Release + +rem : Outfit + Color 17 + Title Delete Machine Cert + +rem : Delete the Cert + certutil -delstore MY %COMPUTERNAME%.zentrale.schwesternschaft-muenchen.de + +:END