Repository navigation
Expand file tree
/
Copy pathMain.ps1
More file actions
212 lines (185 loc) · 10.7 KB
/
Copy pathMain.ps1
File metadata and controls
212 lines (185 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
Add-Type -AssemblyName System.Windows.Forms
# Create the form
$form = New-Object System.Windows.Forms.Form
$form.Text = "Main Installer"
$form.Size = New-Object System.Drawing.Size(520, 400)
$form.StartPosition = "CenterScreen"
# Checkbox for .NET Framework 3.5
$checkboxNetFx = New-Object System.Windows.Forms.CheckBox
$checkboxNetFx.Text = "Enable .NET Framework 3.5"
$checkboxNetFx.AutoSize = $true
$checkboxNetFx.Location = New-Object System.Drawing.Point(20, 20)
$form.Controls.Add($checkboxNetFx)
# Checkbox for Microsoft App Installer
$checkboxAppInstaller = New-Object System.Windows.Forms.CheckBox
$checkboxAppInstaller.Text = "Install Microsoft App Installer"
$checkboxAppInstaller.AutoSize = $true
$checkboxAppInstaller.Checked = $true
$checkboxAppInstaller.Location = New-Object System.Drawing.Point(20, 50)
$form.Controls.Add($checkboxAppInstaller)
# Checkbox for installing additional apps
$checkboxApps = New-Object System.Windows.Forms.CheckBox
$checkboxApps.Text = "Install Additional Apps"
$checkboxApps.AutoSize = $true
$checkboxApps.Checked = $true
$checkboxApps.Location = New-Object System.Drawing.Point(20, 80)
$form.Controls.Add($checkboxApps)
# Checkbox for "Install Floorp + Extras" (checked by default)
$checkboxFloorpExtras = New-Object System.Windows.Forms.CheckBox
$checkboxFloorpExtras.Text = "Install Floorp + Extras"
$checkboxFloorpExtras.AutoSize = $true
$checkboxFloorpExtras.Checked = $true
$checkboxFloorpExtras.Location = New-Object System.Drawing.Point(20, 110)
$form.Controls.Add($checkboxFloorpExtras)
# Checkbox for Disable Services
$checkboxDisableServices = New-Object System.Windows.Forms.CheckBox
$checkboxDisableServices.Text = "Disable Selected Services"
$checkboxDisableServices.AutoSize = $true
$checkboxDisableServices.Checked = $true
$checkboxDisableServices.Location = New-Object System.Drawing.Point(20, 140)
$form.Controls.Add($checkboxDisableServices)
# Apply Button
$button = New-Object System.Windows.Forms.Button
$button.Text = "Apply"
$button.Size = New-Object System.Drawing.Size(80, 30)
$button.Location = New-Object System.Drawing.Point(420, 350)
$form.Controls.Add($button)
# Define the Floorp + Extras installation function
function Install-FloorpExtras {
param (
[string] $ExecutableName = "floorp.exe"
)
$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\$ExecutableName"
try {
# Check if registry key exists
if (-not (Test-Path $registryPath)) {
Write-Output "Registry key for $ExecutableName not found."
return
}
# Get the default value which typically holds the program path
$programPath = (Get-ItemProperty -Path $registryPath -ErrorAction Stop).'(Default)'
if ($programPath -and (Test-Path $programPath)) {
$installDirectory = Split-Path -Path $programPath -Parent
# Create 'distribution' folder if needed
$distributionFolder = Join-Path -Path $installDirectory -ChildPath "distribution"
if (-not (Test-Path $distributionFolder)) {
New-Item -Path $distributionFolder -ItemType Directory | Out-Null
Write-Output "Created folder: $distributionFolder"
}
else {
Write-Output "Folder already exists: $distributionFolder"
}
# Write policies.json
$policiesFilePath = Join-Path -Path $distributionFolder -ChildPath "policies.json"
$jsonContent = @"
{
"policies": {
"Extensions": {
"Install": [
"https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi",
"https://addons.mozilla.org/firefox/downloads/latest/adguard-adblocker/latest.xpi"
],
"InstallSources": [
"https://addons.mozilla.org"
]
}
}
}
"@
# Write JSON to file without BOM
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::WriteAllText($policiesFilePath, $jsonContent, $utf8NoBom)
Write-Output "Created policies.json at: $policiesFilePath"
}
else {
Write-Output "Program path not found in registry for $ExecutableName."
}
}
catch {
Write-Output "Error during Floorp Extras setup: $($_.Exception.Message)"
}
}
# Function to configure services with loops
function Configure-Services {
# List of services to disable
# Script generated by WinScript
# Check if the script is running as admin
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "SilentlyContinue"
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Host "This script requires administrator privileges."`n"Please run WinScript as an administrator." -ForegroundColor Red; pause ; exit }
Write-Host '-- Disabling Manual Services' -ForegroundColor Cyan
$manualServices = @("ALG", "AppMgmt", "AppReadiness", "Appinfo", "AxInstSV", "BDESVC", "BTAGService", "BcastDVRUserService", "BluetoothUserService", "Browser", "CDPSvc", "COMSysApp", "CaptureService", "CertPropSvc", "ConsentUxUserSvc", "CscService", "DevQueryBroker", "DeviceAssociationService", "DeviceInstall", "DevicePickerUserSvc", "DevicesFlowUserSvc", "DisplayEnhancementService", "DmEnrollmentSvc", "DsSvc", "DsmSvc", "EFS", "EapHost", "EntAppSvc", "FDResPub", "FrameServer", "FrameServerMonitor", "GraphicsPerfSvc", "HvHost", "IEEtwCollectorService", "InstallService", "InventorySvc", "IpxlatCfgSvc", "KtmRm", "LicenseManager", "LxpSvc", "MSDTC", "MSiSCSI", "McpManagementService", "MicrosoftEdgeElevationService", "MsKeyboardFilter", "NPSMSvc", "NaturalAuthentication", "NcaSvc", "NcbService", "NcdAutoSetup", "NetSetupSvc", "Netman", "NgcCtnrSvc", "NgcSvc", "NlaSvc", "PNRPAutoReg", "PcaSvc", "PeerDistSvc", "PenService", "PerfHost", "PhoneSvc", "PimIndexMaintenanceSvc", "PlugPlay", "PolicyAgent", "PrintNotify", "PushToInstall", "QWAVE", "RasAuto", "RasMan", "RetailDemo", "RmSvc", "RpcLocator", "SCPolicySvc", "SCardSvr", "SDRSVC", "SEMgrSvc", "SNMPTRAP", "SNMPTrap", "SSDPSRV", "ScDeviceEnum", "SensorDataService", "SensorService", "SensrSvc", "SessionEnv", "SharedAccess", "SmsRouter", "SstpSvc", "StiSvc", "StorSvc", "TapiSrv", "TextInputManagementService", "TieringEngineService", "TokenBroker", "TroubleshootingSvc", "TrustedInstaller", "UdkUserSvc", "UmRdpService", "UserDataSvc", "UsoSvc", "VSS", "VacSvc", "WEPHOSTSVC", "WFDSConMgrSvc", "WMPNetworkSvc", "WManSvc", "WPDBusEnum", "WalletService", "WarpJITSvc", "WbioSrvc", "WdNisSvc", "WdiServiceHost", "WdiSystemHost", "WebClient", "Wecsvc", "WerSvc", "WiaRpc", "WinRM", "WpcMonSvc", "WpnService", "WwanSvc", "autotimesvc", "bthserv", "camsvc", "cbdhsvc", "cloudidsvc", "dcsvc", "defragsvc", "diagsvc", "dmwappushservice", "dot3svc", "edgeupdate", "edgeupdatem", "embeddedmode", "fdPHost", "fhsvc", "hidserv", "icssvc", "lfsvc", "lltdsvc", "lmhosts", "msiserver", "netprofm", "p2pimsvc", "p2psvc", "perceptionsimulation", "pla", "seclogon", "smphost", "svsvc", "swprv", "upnphost", "vds", "vmicguestinterface", "vmicheartbeat", "vmickvpexchange", "vmicrdv", "vmicshutdown", "vmictimesync", "vmicvmsession", "vmicvss", "vmvss", "wbengine", "wcncsvc", "webthreatdefsvc", "wercplsupport", "wisvc", "wlidsvc", "wlpasvc", "wmiApSrv", "workfolderssvc", "wuauserv", "wudfsvc")
$disabledServices = @("AppVClient", "AssignedAccessManagerSvc", "DiagTrack", "DialogBlockingService", "NetTcpPortSharing", "RemoteAccess", "RemoteRegistry", "shpamsvc", "ssh-agent", "tzautoupdate")
$manualServices | ForEach-Object { Set-Service -Name $_ -StartupType Manual }
$disabledServices | ForEach-Object { Set-Service -Name $_ -StartupType Disabled }
# Pause the script
Write-Host "Service configuration complete." -ForegroundColor Cyan
}
# Your Apply button click event
$button.Add_Click({
# Clear the console
Clear-Host
Write-Host "Starting operations..." -ForegroundColor Cyan
# 1. Enable .NET Framework 3.5
if ($checkboxNetFx.Checked) {
Write-Host "Enabling .NET Framework 3.5..." -ForegroundColor Yellow
try {
Enable-WindowsOptionalFeature -Online -FeatureName NetFx3 -All -NoRestart -ErrorAction Stop
Write-Host ".NET Framework 3.5 enabled successfully." -ForegroundColor Green
}
catch {
Write-Host "Error enabling .NET Framework 3.5: $($_.Exception.Message)" -ForegroundColor Red
}
}
# 2. Install Microsoft App Installer
if ($checkboxAppInstaller.Checked) {
Write-Host "Installing Microsoft App Installer..." -ForegroundColor Yellow
try {
winget install --id=Microsoft.AppInstaller --accept-source-agreements --accept-package-agreements
Write-Host "Microsoft App Installer installed successfully." -ForegroundColor Green
}
catch {
Write-Host "Error installing Microsoft App Installer: $($_.Exception.Message)" -ForegroundColor Red
}
}
# 3. Install additional apps
if ($checkboxApps.Checked) {
$apps = @(
"Microsoft.VisualStudioCode",
"abbodi1406.vcredist",
"M2Team.NanaZip",
"IrfanSkiljan.IrfanView",
"IrfanSkiljan.IrfanView.PlugIns",
"CodecGuide.K-LiteCodecPack.Standard",
"Ablaze.Floorp",
"Audacity.Audacity",
"Nilesoft.Shell"
)
foreach ($app in $apps) {
Write-Host "Installing $app ..." -ForegroundColor Cyan
try {
winget install --id=$app --accept-source-agreements --accept-package-agreements --silent
Write-Host "$app installed successfully." -ForegroundColor Green
}
catch {
Write-Host "Error installing $($app): ${($_.Exception.Message)}" -ForegroundColor Red
}
Start-Sleep -Seconds 1
}
Write-Host "All selected apps installed." -ForegroundColor Cyan
}
# 4. Install Floorp + Extras if checked
if ($checkboxFloorpExtras.Checked) {
Write-Host "Installing Floorp + Extras..." -ForegroundColor Yellow
Install-FloorpExtras
}
# 5. Configure services if checkbox checked
if ($checkboxDisableServices.Checked) {
Write-Host "Configuring services (disable then demand)..." -ForegroundColor Yellow
Configure-Services
}
Write-Host "Operations completed." -ForegroundColor Cyan
})
# Show the form
$form.Show()
[System.Windows.Forms.Application]::Run()