From d1f7b4aa13ade30843b4570d048ed550b65c082f Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 29 May 2024 20:40:50 +0200 Subject: Testing --- .config/powershell/bootstrap.ps1 | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) (limited to '.config/powershell/bootstrap.ps1') diff --git a/.config/powershell/bootstrap.ps1 b/.config/powershell/bootstrap.ps1 index 3e1df75..6ee4651 100644 --- a/.config/powershell/bootstrap.ps1 +++ b/.config/powershell/bootstrap.ps1 @@ -10,41 +10,7 @@ $oldUsername = $env:USERNAME function handle_error { param ($message) Write-Host $message -ForegroundColor Red - exit 1 -} - -# Rename the user account -try { - $userName = Get-WmiObject win32_userAccount -Filter "Name='$oldUsername'" - if ($userName) { - $result = $userName.Rename($newUsername) - if ($result -ne 0) { - handle_error "Failed to rename user." - } - } else { - handle_error "User not found." - } - Write-Host "User account renamed successfully." -} catch { - handle_error "Failed to rename user account: $_" -} - -# Rename the user profile folder -try { - Rename-Item -Path "C:\Users\$oldUsername" -NewName "C:\Users\$newUsername" - Write-Host "User profile folder renamed successfully." -} catch { - handle_error "Failed to rename user profile folder: $_" -} - -# Update registry entries -try { - $sid = (Get-WmiObject Win32_UserAccount -Filter "Name='$newUsername'").SID - $regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid" - Set-ItemProperty -Path $regPath -Name "ProfileImagePath" -Value "C:\Users\$newUsername" - Write-Host "Registry updated successfully." -} catch { - handle_error "Failed to update registry: $_" + #exit 1 } # Install Chocolatey @@ -218,4 +184,4 @@ Disable-WindowsKey # Restart to apply changes Write-Host "Restarting system to apply changes..." -Restart-Computer -Force +#Restart-Computer -Force -- cgit v1.2.3