Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) # Installing needed apps choco install dotnet -y choco install vcredist-all -y choco install firefox -y choco install 7zip -y choco install onlyoffice -y choco install adobereader -y choco install sublimetext4 -y choco install vlc -y choco install audacity -y choco install arduino -y Set-LocalUser -Name "Eleve" -PasswordNeverExpires $true -UserMayChangePassword $false -Password ([securestring]::new()) $SecurePassword = ConvertTo-SecureString -String "IPRprof2398" -AsPlainText -Force Set-LocalUser -Name "Prof" -PasswordNeverExpires $true -UserMayChangePassword $false -Password $SecurePassword $SecurePassword = ConvertTo-SecureString -String "Lprsnm4ehk26-" -AsPlainText -Force Set-LocalUser -Name "Admin" -PasswordNeverExpires $true -Password $SecurePassword # Function to load a user's HKU registry hive function UserReg { param ( [string] $Username ) # Get the list of user profiles on the computer $UserProfiles = Get-WmiObject Win32_UserProfile | Where-Object { $_.Special -eq $false } # Search for the user profile based on the username $UserProfile = $UserProfiles | Where-Object { $_.LocalPath.EndsWith("\$Username") } # Check if the user profile exists if ($UserProfile -ne $null) { # Construct the path to the user's NTUSER.DAT file (registry hive) $UserSID = $UserProfile.SID $HivePath = Join-Path -Path $UserProfile.LocalPath -ChildPath "NTUSER.DAT" # Return the user's SID and HKU registry key return $UserSID, "Registry::HKEY_USERS\$UserSID" } else { Write-Host "User profile for $Username not found." return $null, $null } } $TargetUsername = "Eleve" $UserSID, $UserHKUPath = UserReg -Username $TargetUsername if ($UserSID -ne $null -and $UserHKUPath -ne $null) { # Restrict access to Settings $ControlPanelKeyPath = "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" $ControlPanelValueName = "NoControlPanel" if (Test-Path -Path $ControlPanelKeyPath) { $RegistryItem = Get-ItemProperty -Path $ControlPanelKeyPath if ($RegistryItem.PSObject.Properties.Name -contains $ControlPanelValueName) { Set-ItemProperty -Path $ControlPanelKeyPath -Name $ControlPanelValueName -Value 1 } else { New-ItemProperty -Path $ControlPanelKeyPath -Name $ControlPanelValueName -Value 1 -PropertyType DWord } } else { New-Item -Path $ControlPanelKeyPath -Force New-ItemProperty -Path $ControlPanelKeyPath -Name $ControlPanelValueName -Value 1 -PropertyType DWord } # Disable access to regedit $REGKeyPath = "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\System" $REGValueName = "DisableRegistryTools" if (Test-Path -Path $REGKeyPath) { $RegistryItem = Get-ItemProperty -Path $REGKeyPath if ($RegistryItem.PSObject.Properties.Name -contains $REGValueName) { Set-ItemProperty -Path $REGKeyPath -Name $REGValueName -Value 1 } else { New-ItemProperty -Path $REGKeyPath -Name $REGValueName -Value 1 -PropertyType DWord } } else { New-Item -Path $REGKeyPath -Force New-ItemProperty -Path $REGKeyPath -Name $REGValueName -Value 1 -PropertyType DWord } # Restrict access to Command Prompt $CMDKeyPath = "$UserHKUPath\Software\Policies\Microsoft\Windows\System" $CMDValueName = "DisableCMD" if (Test-Path -Path $CMDKeyPath) { $RegistryItem = Get-ItemProperty -Path $CMDKeyPath if ($RegistryItem.PSObject.Properties.Name -contains $CMDValueName) { Set-ItemProperty -Path $CMDKeyPath -Name $CMDValueName -Value 1 } else { New-ItemProperty -Path $CMDKeyPath -Name $CMDValueName -Value 1 -PropertyType DWord } } else { New-Item -Path $CMDKeyPath -Force New-ItemProperty -Path $CMDKeyPath -Name $CMDValueName -Value 1 -PropertyType DWord } # Add entries to DisallowRun for cmd.exe and powershell.exe $DisallowRunKeyPath = "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun" if (Test-Path -Path $DisallowRunKeyPath) { Set-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun" -Value 1 if ($DisallowRunKeyPath.PSObject.Properties.Name -contains "1") { Set-ItemProperty -Path $DisallowRunKeyPath -Name "1" -Value "cmd.exe" -PropertyType String } else { New-ItemProperty -Path $DisallowRunKeyPath -Name "1" -Value "cmd.exe" } if ($DisallowRunKeyPath.PSObject.Properties.Name -contains "2") { New-ItemProperty -Path $DisallowRunKeyPath -Name "2" -Value "powershell.exe" -PropertyType String } else { New-ItemProperty -Path $DisallowRunKeyPath -Name "2" -Value "powershell.exe" } if ($DisallowRunKeyPath.PSObject.Properties.Name -contains "3") { New-ItemProperty -Path $DisallowRunKeyPath -Name "3" -Value "powershell_ise.exe" -PropertyType String } else { New-ItemProperty -Path $DisallowRunKeyPath -Name "3" -Value "powershell_ise.exe" } } else { New-Item -Path $DisallowRunKeyPath -Force Set-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun" -Value 1 New-ItemProperty -Path $DisallowRunKeyPath -Name "1" -Value "cmd.exe" -PropertyType String New-ItemProperty -Path $DisallowRunKeyPath -Name "2" -Value "powershell.exe" -PropertyType String New-ItemProperty -Path $DisallowRunKeyPath -Name "3" -Value "powershell_ise.exe" -PropertyType String } } else { Write-Host "Unable to get the user's HKU registry." }