From 2a901a2dc5532ace37a16977a966e0e0d00fcdc9 Mon Sep 17 00:00:00 2001 From: bschaper Date: Thu, 12 Dec 2024 15:25:07 -0600 Subject: [PATCH] Cleaned up Taskbar Layouts and Removing Public Shortcuts --- Patches/Windows/Delete-Public-Shortcuts.ps1 | 22 ++++++++++ .../{ => Windows}/Initial-Windows-Updates.ps1 | 0 StartLayouts/Set-Taskbar-Layout.ps1 | 16 +++++++ TCSE-Computer-Deploy.bat | 42 ++++--------------- 4 files changed, 47 insertions(+), 33 deletions(-) create mode 100644 Patches/Windows/Delete-Public-Shortcuts.ps1 rename Patches/{ => Windows}/Initial-Windows-Updates.ps1 (100%) create mode 100644 StartLayouts/Set-Taskbar-Layout.ps1 diff --git a/Patches/Windows/Delete-Public-Shortcuts.ps1 b/Patches/Windows/Delete-Public-Shortcuts.ps1 new file mode 100644 index 0000000..8e58e90 --- /dev/null +++ b/Patches/Windows/Delete-Public-Shortcuts.ps1 @@ -0,0 +1,22 @@ +# Remove All Shortcuts from Public Desktop Folder + +# Set the path to the Public Desktop folder +$publicDesktop = "$env:Public\Desktop" + +# Counter for deleted shortcuts +$deletedCount = 0 + +# Check if the Public Desktop folder exists +if (!(Test-Path $publicDesktop)) { + Write-Warning "Error: Public Desktop folder not found." + exit 1 +} + +# Remove all .lnk files from the Public Desktop +Get-ChildItem $publicDesktop -Filter "*.lnk" | ForEach-Object { + Remove-Item $_.FullName -Force + $deletedCount++ +} + +# Display results +Write-Host "Deleted $deletedCount shortcut(s) from the Public Desktop." \ No newline at end of file diff --git a/Patches/Initial-Windows-Updates.ps1 b/Patches/Windows/Initial-Windows-Updates.ps1 similarity index 100% rename from Patches/Initial-Windows-Updates.ps1 rename to Patches/Windows/Initial-Windows-Updates.ps1 diff --git a/StartLayouts/Set-Taskbar-Layout.ps1 b/StartLayouts/Set-Taskbar-Layout.ps1 new file mode 100644 index 0000000..875803f --- /dev/null +++ b/StartLayouts/Set-Taskbar-Layout.ps1 @@ -0,0 +1,16 @@ +# Define the directory containing the .reg files +$regFilesDir = "C:\Scripts\StartLayouts" + +# Get an array of all .reg files in the directory +$regFiles = Get-ChildItem -Path $regFilesDir -Filter "*.reg" + +# Loop through each .reg file and import it +foreach ($regFile in $regFiles) { + reg import $regFile.FullName +} + +# Restart File Explorer +Taskkill /F /IM explorer.exe +Start-Process explorer.exe + +Write-Host "Taskbar layout successfully imported..." \ No newline at end of file diff --git a/TCSE-Computer-Deploy.bat b/TCSE-Computer-Deploy.bat index 69fd853..851c07d 100644 --- a/TCSE-Computer-Deploy.bat +++ b/TCSE-Computer-Deploy.bat @@ -47,39 +47,15 @@ winget install --exact --id Zoom.Zoom --silent echo Installing Adobe Reader... winget install --exact --id Adobe.Acrobat.Reader.64-bit --silent -::: Define Taskbar Layout Path -set "REG_FILES_DIR=C:\Scripts\StartLayouts" +:: Set Taskbar Layout for All Users +echo Setting Taskbar Layout... +powershell -ExecutionPolicy Bypass -File "C:\Scripts\StartLayouts\Set-Taskbar-Layout.ps1" +echo Taskbar Layout is Set... -::: Loop through each .reg file in the directory -for %%f in (%REG_FILES_DIR%\*.reg) do ( - reg import "%%f" -) - -echo Taskbar layout successfully imported... - -:: Remove All Shortcuts from Public Desktop Folder -:: Set the path to the Public Desktop folder -set "PUBLIC_DESKTOP=%PUBLIC%\Desktop" - -:: Counter for deleted shortcuts -set "deleted_count=0" - -:: Check if the Public Desktop folder exists -if not exist "%PUBLIC_DESKTOP%" ( - echo Error: Public Desktop folder not found. - exit /b 1 -) - -:: Remove all .lnk files from the Public Desktop -for %%F in ("%PUBLIC_DESKTOP%\*.lnk") do ( - del "%%F" - if !errorlevel! equ 0 ( - set /a "deleted_count+=1" - ) -) - -:: Display results -echo Deleted !deleted_count! shortcut(s) from the Public Desktop. +:: Delete Shortcuts from Public Desktop Folder +echo Deleting Shortcuts from Public Desktop Folder... +powershell -ExecutionPolicy Bypass -File "C:\Scripts\Patches\Windows\Delete-Public-Shortcuts.ps1" +echo Shortcuts Have Been Deleted... :: GCPW Add Allowed Domain to Registry echo Adding Domain to GCPW Registry... @@ -97,7 +73,7 @@ powershell Copy-Item 'C:\Scripts\TCSE-Login.vbs' 'C:\ProgramData\Microsoft\Windo echo Successfully Copied Login Scripts... :: Perform Windows Updates -powershell -ExecutionPolicy Bypass -File "C:\Scripts\Patches\Initial-Windows-Updates.ps1" +powershell -ExecutionPolicy Bypass -File "C:\Scripts\Patches\Windows\Initial-Windows-Updates.ps1" :: Restart System echo Restarting system in 2.5 minutes...