Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Configure Windows 7 with Powershell my way

I recently reinstalled Windows 7 in some virtual machines. I was following my process to configure the system in a usable way, which involves setting some things like a black background on the login screen, hiding "Libraries" and other cruft from Windows Explorer (this is before it was renamed to File Explorer), and so on.

I have applied my professional Powershell skills to this old document, with a curious legacy twist because Powershell 2.0 is missing some features I would have found useful. Now I've turned my 15-minute set of steps into a 10-minute set of steps, for the thing I do once every 7 years, hooray! It only took me a few fun hours.

Here is the instructions for customizing my Windows 7 install, which is the basis (and comments) for the following powershell script.

files/2025/listings/windows-7-config.txt (Source)

Filename: windows-7-config.txt
Location: bgstack15.ddns.net/blog
Author: bgstack15
Startdate: 2013-04-15
Title: Standard Settings for a New W7 System
Purpose: To provide a standard for settings and customization
History:
Usage:
Reference:
   %Setups%\Default\W8def.txt
Improve:
# Install Windows 7 Professional
# Iso files:
#    /mnt/public/Support/SetupsBig/en_windows_7_professional_with_sp1_x86_dvd_u_677056.iso
#    /mnt/public/Support/SetupsBig/en_windows_7_professional_x64_dvd_x15-65805.iso
Physical machine, from Windows
- Copy the .iso contents to a blank hdd.
- Run "E:\boot\bootsect.exe /nt60 e:" for the drive letter in use for this hdd.
- Mark the partition as active in "Compmgmt.msc."
- Place the drive in the target system and install Windows 7 to its own drive.
- Select username bgstack15-local\\[old domain pw]
- Enable rdp connections in "System Properties\Remote tab"
- Rename "C:\support" as "C:\tsupport" or otherwise.
Copy %Setups% as C:\Support\Setups
Md "C:\Support\Installed"
Create "C:\Support\Installed\$HOST.txt"
Disable UAC
- Start menu\search box "uac"\"Change User Account Control Settings"
   - Set slider to bottom, "Never notify"
Configure Windows interface and default settings
- Enable network sharing features.
   - Control Panel\Network and Internet Settings\Network and Sharing Center\"Change Advanced Sharing Settings"
   - Domain profiles: Turn on network discovery, Turn on file and printer sharing
   - To allow HSP\SERVER access, visit "Control Panel\Network and Internet\Network and Sharing Center" and select "Change advanced sharing settings" on the left. On the bottom of this screen is "Allow user accounts and passwords to connect to other computers." Enable it.
- Personalize the taskbar.
   - Unpin everything from the taskbar: IE, Explorer, Media Player
   - Right-click Taskbar, Properties\Taskbar tab--> unlock taskbar, use small icons, never combine/hide labels
   - Create Quicklaunch toolbar.
     - Right-click Taskbar, Toolbars\New toolbar--> %AppData%\Roaming\Microsoft\Internet Explorer\Quick Launch
     - Right-click this new toolbar--> Uncheck show title, uncheck show text
     - Arrange toolbar to be on far left.
     - Delete the 2 icons there: show desktop, switch between windows.
   - Drag taskbar to be 2small-icons tall.
- Personalize Windows: Try "C:\Support\Setups\Default\Albion-Desktops-baseline.theme"
   - Right-click Desktop\Properties-->Windows Classic theme
   - Desktop color black
   - Adjust color scheme to have red titlebar and selection: transform the numbers RGB --> BGR.
   - Save theme if not in RDP and you were able to adjust the gradient color of titlebars also.
   - Right-click clock\Adjust date and time\Change date and time\Change calendar settings\
     - Date tab\Short date: YYYY-mm-dd
     - Currency tab\negative currenty: $-1.1 (down 2)
     - Time tab\Both short and long time: HH:mm.ss
   - Control Panel\Ease of Access\Ease of Access Center\"Make the keyboard easier to use"\underline keyboard shortcuts and access keys
- Personalize Explorer.
   - Tools\Folder options\
   - Check both boxes in General tab\Navigation pane (show all folders, expand to current folder)
   - View tab\ (See %setups%\Default\Explorer01.png for settings)
   - Apply to all folders
   - View menu\
     - Details (ALT+V,D)
     - Group by none (ALT+V,P,N)
     - Status bar (ALT+V,B)
- Personalize desktop
   - Delete files desktop.ini from desktop
   - Right-click desktop\View\"small icons"
   - Empty Recycle Bin
Adjust power settings (for battery-enabled devices)
Adjust drives
- Change CD drive letter to F: using Compmgmt.msc
- Rename C: to "C_$HOST"
Update Windows.
- Run %Setups%\Win7\dotNetFx40_Full_x86_x64.exe
- Configure Windows Updates
  - Set option to "Never check for updates."
Adjust Explorer mostly with registry settings
- Try file "C:\Support\Setups\Default\W7_explorer.reg"
- Only x64 systems need the Wow6432Node directory.
- might need to allow permission by right-clicking and allowing all users permissions to these keys.
- Hide libraries.
   - [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{031E4825-7B94-4dc3-B131-E946B44C8DD5}]
   - [-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{031E4825-7B94-4dc3-B131-E946B44C8DD5}]
- Hide Favorites.
   - HKEY_CLASSES_ROOT\CLSID\{323CA680-C24D-4099-B94D-446DD2D7249E}\ShellFolder changing "Attributes" to 0xa9400100
- Hide user folder.
   - HKEY_CLASSES_ROOT\CLSID\{59031a47-3f72-44a7-89c5-5595fe6b30ee}\ShellFolder changing "Attribute" to 0xf094012d
- Remove homegroups.
   - services.msc\"Homegroup Provider" disabled and stopped.
- Hide Action Center from system tray
   - Systray\More icons\Customize...\"Turn system icons on or off"
   - Set Action Center to off.
- Restarting Explorer is required to take effect (Logon Screen Tweaker below will do that automatically!).
- Rename C:\autorun.inf to autoruna.inf to prevent the disk icon from looking like the Setup icon.
- Change NIC names to typeable format
   - "Local Area Connection" --> "NIC"
   - "Wireless ..." "WNIC"
   - If more than one of a type, do "NIC1" "NIC2" etc.
Configure msconfig
- msconfig\boot tab
- Remove "Windows Setup" option
- Check "Make all boot settings permanent"
- Save and close
Run Logon Screen Tweaker
- Use image "C:\Support\Setups\Default\black.png"
Install 7+ Taskbar Tweaker (7tt_setup.exe)
- Refer to %setups%\default\7tt.png
Install Classic Shell
- Load default settings from "C:\Support\Setups\Default\ClassicShell_Start_Menu.xml"
- In the Classic start menu, set "Default Programs" link to the name "is $HOST"
- Change user picture
   - Copy %Setups%\Default\user01.jpg to C:\Support\Installed\user02.jpg
   - Use pbrush to add opaque text overlay in bottom right: "$HOST" in size 12 Courier New font.
   - Use real Start menu to set photo.
Install Notepad++
- Plugins menu\Plugin Manager\"Show Plugin Manager"
- Check "Compare"
- Check "TextFX Characters"
- Select Install and restart Npp
- Adjust shortcuts
   - Settings menu\"Shortcut mapper..."
     - Main menu tab\271 Run... "none"
     - Plugins tab\193 I:Date & Time - short format "F5"
- Settings menu\Preferences...
   - Auto-Completion tab\"Enable auto-completion on each input" unchecked
   - Misc tab\"Document swicher" unchecked
   
Install NotepadReplacer
- Point to "C:\Program Files\Notepad++\notepad++.exe"
- Copy %Setups%\notepadex.exe to C:\Windows\System32\
7-zip
Adobe Acrobat Reader 6.0
Irfanview 4.44 and all plugins
PrimoPDF
ArsClip
- Extract the exe to C:\Program Files (x86)\Arsclip
- Regedit\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run\"Arsclip" reg_expand_sz:"C:\Program Files (x86)\Arsclip\Arsclip.exe"
- Adjust NTFS permissions on C:\Program Files (x86)\Arsclip to allow all users full access
VLC
VirtualDrivePro 15
- clear cabinet
- Set drives up to 3 total for H, I, J.
- Refer to %setups%\default\VDM.png
Winkey replacement-- AutoHotKey
- Install AutoHotKey
- Copy %setups%\Default\Shortcut_keys.ahk to "C:\Support\Installed\Shortcut_keys.ahk"
- regedit\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run\"Shortcut keys"
   - value reg_expand_sz:"C:\Program Files\AutoHotKey\AutoHotKey.exe" "C:\Support\Installed\Shortcut_keys.ahk"
- Adjust NTFS permissions on C:\Program Files\AutoHotKey to allow all users full access
Office 2013 (from iso with VDP)
- See %setups%\Default\O2013def.txt
Map network shares
- Credential Manager
   - server1.ipa.internal.com ipa\bgstack15 [old domain password]
- Make a shortcut in %Appdata%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
   - C:\Support\Installed\map.bat "C:\Support\Installed\map.csv"

files/2025/listings/windows-7-config.ps1 (Source)

# File: windows-7-config.ps1
# Location: bgstack15.ddns.net/blog
# Author: bgstack15
# Startdate: 2025-06-26 13:35
# Title: Automate Some Steps from W7def
# Project: SETUPS directory
# Purpose: Automate some of the steps from W7def.txt, in Windows 7 pwsh 2.0
# History:
# Usage:
#    If possible, run the whole thing in admin powershell window, but otherwise copy-paste each section as you get to it in W7def.txt
# Reference:
#    https://powershellcommands.com/set-acl-powershell
#    https://stackoverflow.com/questions/70049129/set-a-hex-registry-value-with-powershell
#    https://sudhakaryblog.wordpress.com/2019/09/16/requested-registry-access-is-not-allowed/
#    https://stackoverflow.com/questions/24366162/set-acl-requested-registry-access-is-not-allowed
# Improve:
# Dependencies:
#    Designed for Windows 7 with base powershell 2.0, which limits a few things
# Documentation:
#    This is designed to implement as much as possible from windows-7-config.txt and no more. NOTE: It does not implement everything, primarily installing applications.
Remove-Item HKLM:\"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{031E4825-7B94-4dc3-B131-E946B44C8DD5}"
Remove-Item HKLM:\"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{031E4825-7B94-4dc3-B131-E946B44C8DD5}"
Function Grant-Acl-To-Path {
   [CmdletBinding()]
   # Future improvement: calculate root key from any proper registry path
   param(
       ## appears to be unsupported in Powershell 2.0 on Windows 7
       #[ArgumentCompleter({
       #  enum PathTypeEnum { Filesystem = 1; Registry = 2; }
       #  [PathTypeEnum].GetEnumValues()
       #})]
       #[ValidateScript({
       #  enum PathTypeEnum { Filesystem = 1; Registry = 2; }
       #  [PathTypeEnum]$_
       #})]
       [Parameter(Mandatory=$false)][string]$PathType = "Filesystem"
      ,[Parameter(Mandatory= $true)][string]$Path = ""
      ,[Parameter(Mandatory=$false)][string]$rootKey = "HKCR"
      ,[Parameter(Mandatory= $true)][string]$Principal = "BUILTIN\Administrator"
      ,[Parameter(Mandatory= $true)][string]$Control = "FullControl"
      ,[Parameter(Mandatory= $true)][string]$AllowOrDeny = "Allow"
   )
   Write-Verbose $PathType
   If ($PathType -eq "Registry") {
      switch -regex ($rootKey) {
         'HKCU|HKEY_CURRENT_USER'    { $rootKeyname = 'CurrentUser' }
         'HKLM|HKEY_LOCAL_MACHINE'   { $rootKeyname = 'LocalMachine' }
         'HKCR|HKEY_CLASSES_ROOT'    { $rootKeyname = 'ClassesRoot' }
         'HKCC|HKEY_CURRENT_CONFIG'  { $rootKeyname = 'CurrentConfig' }
         'HKU|HKEY_USERS'            { $rootKeyname = 'Users' }
      }
      $key = [Microsoft.Win32.Registry]::$rootKeyname.OpenSubKey($Path,[Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubtree,[System.Security.AccessControl.RegistryRights]::ChangePermissions)
      $rule = New-Object System.Security.AccessControl.RegistryAccessRule($Principal,$Control,$AllowOrDeny)
      $acl = $key.GetAccessControl()
      $acl.SetAccessRule($rule)
      Return $key.SetAccessControl($acl)
   }
   Elseif ($PathType -eq "Filesystem") {
      $acl = Get-Acl -Path $Path -Verbose:$Verbose
      $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($Principal,$Control,$AllowOrDeny)
      $acl.SetAccessRule($rule)
      Set-Acl -Path $Path -AclObject $acl -Verbose:$Verbose
   }
   Else {
      Write-Error "Invalid PathType chosen. Use FileSystem or Registry."
   }
}
Function Make-Shortcut {
   [CmdletBinding()]
   param(
       [Parameter(Mandatory= $true)][string]$Source
      ,[Parameter(Mandatory= $true)][string]$DestinationFile
      ,[Parameter(Mandatory=$false)][string]$Arguments
      ,[Parameter(Mandatory=$false)][string]$IconLocation
   )
   $WshShell = New-Object -COMObject WScript.Shell
   $Shortcut = $WshShell.CreateShortcut($DestinationFile)
   $Shortcut.TargetPath = $Source
   If ($Arguments) { $Shortcut.Arguments = $Arguments }
   If ($IconLocation) { $Shortcut.IconLocation = $IconLocation }
   $Shortcut.Save()
}
$RegPath = "CLSID\{323CA680-C24D-4099-B94D-446DD2D7249E}\ShellFolder"
Grant-Acl-To-Path -Path $RegPath -rootKey "HKCR" -Principal "BUILTIN\Administrators" -Control "FullControl" -AllowOrDeny "Allow" -PathType Registry
Set-ItemProperty -Type DWORD -Value 0xA9400100 -Name Attributes -LiteralPath "Registry::HKEY_CLASSES_ROOT\$($RegPath)"
$RegPath = "CLSID\{59031a47-3f72-44a7-89c5-5595fe6b30ee}\ShellFolder"
Grant-Acl-To-Path -Path $RegPath -rootKey "HKCR" -Principal "BUILTIN\Administrators" -Control "FullControl" -AllowOrDeny "Allow" -PathType Registry
Set-ItemProperty -Type DWORD -Value 0xf094012d -Name Attributes -LiteralPath "Registry::HKEY_CLASSES_ROOT\$($RegPath)"
Get-Service -Name HomeGroupProvider | Set-Service -StartupType Disabled
Set-ItemProperty -Path "Registry::HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run" -Name "Arsclip" -Type "string" -Value "C:\Program Files (x86)\ArsClip\ArsClip.exe"
Write-Host "For VDPsecond"
Get-WmiObject win32_networkadapterconfiguration | select Description, MACAddress | ? {$_.MACAddress -ne $null}
New-Item -Path "C:\Support" -Name "Installed" -Type Directory -ErrorAction SilentlyContinue
Copy-Item -Path "C:\Support\Setups\Default\Shortcut_keys.ahk" -Destination "C:\Support\Installed"
Set-ItemProperty -Path "Registry::HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run" -Name "Shortcut-Keys" -Type "ExpandString" -Value "`"C:\Program Files\AutoHotKey\AutoHotKey.exe`" `"C:\Support\Installed\Shortcut_keys.ahk`""
Grant-Acl-To-Path -Path "C:\Program Files (x86)\ArsClip" -principal "BUILTIN\Users" -Control "FullControl" -AllowOrDeny "Allow" -PathType Filesystem
# Make shortcut
Copy-Item -Path "C:\Support\Setups\Default\map.bat" -Destination "C:\Support\Installed"
Copy-Item -Path "C:\Support\Setups\Default\map.csv" -Destination "C:\Support\Installed"
Make-Shortcut -Source "C:\Support\Installed\map.bat" -Arguments "C:\Support\Installed\map.csv" -DestinationFile "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\map.lnk" -IconLocation "%SystemRoot%\system32\SHELL32.dll,148"

Comments