From 44f8386cec029eb2e336df8f5a1e96ae15a6fc8d Mon Sep 17 00:00:00 2001 From: "Eric D. Rohler" Date: Fri, 2 Jul 2021 11:09:42 -0400 Subject: [PATCH] update install script --- install.ps1 | 65 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/install.ps1 b/install.ps1 index 6601cae..2c86469 100644 --- a/install.ps1 +++ b/install.ps1 @@ -8,28 +8,69 @@ # } # Disable UAC -Try { - reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /t REG_DWORD /f /v "EnableLUA" /d "0" - Write-Host "UAC is now disabled." -} -Catch { - Write-Host "Error - Exception caught in disabling UAC : $error[0]" + +$uac_reg_value = Get-ItemPropertyValue -Path Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA + +if(-not $uac_reg_value -eq 0) +{ + Try { + REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /t REG_DWORD /f /v "EnableLUA" /d "0" + Write-Host "UAC is now disabled." + } + Catch { + Write-Host "Error - Exception caught in disabling UAC : $error[0]" + } +} else { + Write-Host "UAC is Disabled" } + # Enable Developer Mode -reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1" /t REG_DWORD /f /v "AllowAllTrustedApps" /d "1" +$dev_mode_alldev_reg_value = Get-ItemPropertyValue -Path Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock -Name AllowDevelopmentWithoutDevLicense +$dev_mode_allapp_reg_value = Get-ItemPropertyValue -Path Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock -Name AllowAllTrustedApps + +if(-not $dev_mode_alldev_reg_value -eq 1 -or -not $dev_mode_allapp_reg_value -eq 1) +{ + try { + REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1" /t REG_DWORD /f /v "AllowAllTrustedApps" /d "1" + } + catch { + Write-Host "Error - Exception caught in Enabling Developer Mode: $error[0]" + } +} else { + write-Host "Developer Mode is Enabled" +} # Set environmenmt variables ## CMDER_ROOT -[System.Environment]::SetEnvironmentVariable('CMDER_ROOT',"$($env:USERPROFILE)\Cmder", [System.EnvironmentVariableTarget]::Machine) +if(-not $env:CMDER_ROOT) +{ + [System.Environment]::SetEnvironmentVariable('CMDER_ROOT',"$($env:USERPROFILE)\Cmder", [System.EnvironmentVariableTarget]::Machine) +} +else { + Write-Host "CMDER_ROOT=$env:CMDER_ROOT" +} # DEV_PATH --Use this per-machine, i.e. laptops sometimes only have a single disk and desktops have multiple disks -$dev_path = Read-Host -Prompt 'Input the Repos Path:' -[System.Environment]::SetEnvironmentVariable('DEV_PATH', $dev_path, [System.EnvironmentVariableTarget]::Machine) +if(-not $env:DEV_PATH) +{ + $dev_path = Read-Host -Prompt 'Input the Repos Path:' + [System.Environment]::SetEnvironmentVariable('DEV_PATH', $dev_path, [System.EnvironmentVariableTarget]::Machine) +} +else { + Write-Host "DEV_PATH=$env:DEV_PATH" +} + # NC_PATH --Use this per-machine -$nc_path = Read-Host -Prompt 'Input the Nextcloud Path:' -[System.Environment]::SetEnvironmentVariable('NC_PATH', $nc_path, [System.EnvironmentVariableTarget]::Machine) +if(-not $env:NC_PATH) +{ + $nc_path = Read-Host -Prompt 'Input the Nextcloud Path:' + [System.Environment]::SetEnvironmentVariable('NC_PATH', $nc_path, [System.EnvironmentVariableTarget]::Machine) +} else { + Write-Host "NC_PATH=$env:NC_PATH" +} + # User Profile Write-Host "User Profile Directory: $($env:USERPROFILE)"