Fix scripts

This commit is contained in:
2023-10-23 16:33:08 +00:00
parent e333365da4
commit b76e612f35
3 changed files with 31 additions and 39 deletions

View File

@@ -1,5 +1,5 @@
# Activate windows
irm https://massgrave.dev/get | iex
Invoke-RestMethod https://massgrave.dev/get | Invoke-Expression
#Download temp files
$tmpPath = Join-Path $env:LOCALAPPDATA "Temp"
@@ -67,7 +67,7 @@ foreach ($fileInfo in $filesToDownload) {
}
}
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'))
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Setup users
Set-LocalUser -Name "Eleve" -PasswordNeverExpires $true -UserMayChangePassword $false -Password ([securestring]::new())
@@ -84,9 +84,8 @@ function UserReg {
)
$UserProfiles = Get-WmiObject Win32_UserProfile | Where-Object { $_.Special -eq $false }
$UserProfile = $UserProfiles | Where-Object { $_.LocalPath.EndsWith("\$Username") }
if ($UserProfile -ne $null) {
if ($null -ne $UserProfile) {
$UserSID = $UserProfile.SID
$HivePath = Join-Path -Path $UserProfile.LocalPath -ChildPath "NTUSER.DAT"
return $UserSID, "Registry::HKEY_USERS\$UserSID"
} else {
Write-Host "User profile for $Username not found."
@@ -117,7 +116,7 @@ function SetRegistry {
$TargetUsername = "Eleve"
$UserSID, $UserHKUPath = UserReg -Username $TargetUsername
# Add restriction
if ($UserSID -ne $null -and $UserHKUPath -ne $null) {
if ($null -ne $UserSID -and $null -ne $UserHKUPath) {
# Restrict access to Settings
$ControlPanelKeyPath = "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
$ControlPanelValueName = "NoControlPanel"
@@ -177,15 +176,14 @@ function InstallExe {
if (-not (Test-Path -Path $targetPath -PathType Container)) {
New-Item -Path $targetPath -ItemType Directory
}
$appFilePath = Join-Path $tmpPath $app
Copy-Item -Path (Join-Path $tmpPath $app) -Destination $targetPath -Force
createShortcut -exe (Join-Path $targetPath $app) -app $appName
}
function InstallZipSetup {
param (
[string] $zip
[string] $exe,
[string] $zip,
[string] $exe
)
$zipName = [System.IO.Path]::GetFileNameWithoutExtension($zip)
Expand-Archive -Path (Join-Path $tmpPath $zip) -DestinationPath $tmpPath -Force
@@ -194,9 +192,9 @@ function InstallZipSetup {
function InstallZip {
param (
[string] $zip
[string] $zip,
[string] $exe,
[string] $app,
[string] $app
)
$zipName = [System.IO.Path]::GetFileNameWithoutExtension($zip)
@@ -207,8 +205,8 @@ function InstallZip {
function createShortcut {
param (
[string] $exe
[string] $app,
[string] $exe,
[string] $app
)
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($(Join-Path $env:PUBLIC "Desktop\$app.lnk"))