Skip to content

Commit a58a726

Browse files
committed
Added Update script (still in progress)
1 parent 6810054 commit a58a726

File tree

2 files changed

+157
-2
lines changed

2 files changed

+157
-2
lines changed

Update.ps1

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Load Windows Forms
2+
Add-Type -AssemblyName System.Windows.Forms
3+
Add-Type -AssemblyName System.Drawing
4+
5+
# Function to get the current version from the registry
6+
function Get-CurrentVersion {
7+
$modelKey = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation'
8+
$orgKey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
9+
10+
$modelVersion = (Get-ItemProperty -Path $modelKey).Model
11+
$orgVersion = (Get-ItemProperty -Path $orgKey).RegisteredOrganization
12+
13+
return $modelVersion, $orgVersion
14+
}
15+
16+
# Function to update the UI
17+
function Update-UI {
18+
param (
19+
[string]$version,
20+
[array]$availableUpdates,
21+
[hashtable]$changeLogs
22+
)
23+
24+
# Create the form
25+
$form = New-Object System.Windows.Forms.Form
26+
$form.Text = "Update Manager"
27+
$form.Size = New-Object System.Drawing.Size(400, 500) # Size of the form
28+
$form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen
29+
$form.BackColor = [System.Drawing.Color]::FromArgb(240, 240, 240) # Light background color
30+
31+
# Label for current version
32+
$label = New-Object System.Windows.Forms.Label
33+
$label.Text = "Current Version: $version`nAvailable Updates:"
34+
$label.AutoSize = $true
35+
$label.Location = New-Object System.Drawing.Point(10, 10)
36+
$label.Font = New-Object System.Drawing.Font("Segoe UI", 10, [System.Drawing.FontStyle]::Bold)
37+
$form.Controls.Add($label)
38+
39+
# CheckBox list for available updates
40+
$checkBoxes = @()
41+
$yPos = 50
42+
43+
foreach ($update in $availableUpdates) {
44+
$checkBox = New-Object System.Windows.Forms.CheckBox
45+
$checkBox.Text = $update
46+
$checkBox.Location = New-Object System.Drawing.Point(10, $yPos)
47+
$checkBox.Font = New-Object System.Drawing.Font("Segoe UI", 9)
48+
$checkBox.BackColor = [System.Drawing.Color]::FromArgb(240, 240, 240)
49+
$checkBoxes += $checkBox
50+
$form.Controls.Add($checkBox)
51+
$yPos += 30
52+
}
53+
54+
# RichTextBox for showing change logs
55+
$richTextBox = New-Object System.Windows.Forms.RichTextBox
56+
$richTextBox.Location = New-Object System.Drawing.Point(10, $yPos)
57+
$richTextBox.Size = New-Object System.Drawing.Size(360, 300) # Further increased vertical size
58+
$richTextBox.ReadOnly = $true
59+
$richTextBox.ScrollBars = [System.Windows.Forms.RichTextBoxScrollBars]::Vertical
60+
$richTextBox.Font = New-Object System.Drawing.Font("Segoe UI", 9)
61+
$richTextBox.BackColor = [System.Drawing.Color]::FromArgb(255, 255, 255) # White background
62+
$richTextBox.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D
63+
$form.Controls.Add($richTextBox)
64+
65+
# Update changelog based on selection
66+
foreach ($checkBox in $checkBoxes) {
67+
$checkBox.Add_CheckedChanged({
68+
$richTextBox.Clear()
69+
$selectedUpdates = $checkBoxes | Where-Object { $_.Checked } | ForEach-Object { $_.Text }
70+
if ($selectedUpdates.Count -gt 0) {
71+
foreach ($update in $selectedUpdates) {
72+
$richTextBox.SelectionFont = New-Object System.Drawing.Font("Segoe UI", 9, [System.Drawing.FontStyle]::Bold)
73+
$richTextBox.AppendText("Changelogs for $($update):`n") # Bold changelog headers
74+
$richTextBox.SelectionFont = New-Object System.Drawing.Font("Segoe UI", 9) # Reset to normal
75+
$changeLogEntries = $changeLogs[$update] -split "`n"
76+
for ($i = 0; $i -lt $changeLogEntries.Count; $i++) {
77+
$richTextBox.AppendText("$($i + 1). $($changeLogEntries[$i])`n") # Fixed variable reference
78+
}
79+
$richTextBox.AppendText("`n")
80+
}
81+
}
82+
})
83+
}
84+
85+
# Update button
86+
$updateButton = New-Object System.Windows.Forms.Button
87+
$updateButton.Text = "Apply Updates"
88+
$updateButton.Location = New-Object System.Drawing.Point(10, [int]($yPos + 310)) # Adjusted placement of the button
89+
$updateButton.Size = New-Object System.Drawing.Size(360, 30)
90+
$updateButton.Font = New-Object System.Drawing.Font("Segoe UI", 10, [System.Drawing.FontStyle]::Bold)
91+
$updateButton.BackColor = [System.Drawing.Color]::FromArgb(0, 120, 215) # Button color
92+
$updateButton.ForeColor = [System.Drawing.Color]::White # Button text color
93+
$updateButton.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat # Flat button style
94+
$updateButton.Add_Click({
95+
$selectedUpdates = $checkBoxes | Where-Object { $_.Checked } | ForEach-Object { $_.Text }
96+
if ($selectedUpdates.Count -gt 0) {
97+
foreach ($selectedUpdate in $selectedUpdates) {
98+
# Call the function to apply the update
99+
Apply-Update $selectedUpdate
100+
}
101+
[System.Windows.Forms.MessageBox]::Show("Selected updates have been applied.", "Updates Applied")
102+
$form.Close()
103+
} else {
104+
[System.Windows.Forms.MessageBox]::Show("Please select at least one update.", "No Selection")
105+
}
106+
})
107+
$form.Controls.Add($updateButton)
108+
109+
# Show the form
110+
$form.ShowDialog() | Out-Null
111+
}
112+
113+
# Function to apply the update
114+
function Apply-Update {
115+
param (
116+
[string]$updateVersion
117+
)
118+
# Placeholder for update commands based on the version
119+
switch ($updateVersion) {
120+
"4.1" {
121+
# Add commands for 4.1 update
122+
Write-Host "Applying update 4.1..."
123+
}
124+
"4.5" {
125+
# Add commands for 4.5 update
126+
Write-Host "Applying update 4.5..."
127+
}
128+
default {
129+
Write-Host "No actions defined for version: $updateVersion"
130+
}
131+
}
132+
}
133+
134+
# Main execution
135+
$currentVersion, $orgVersion = Get-CurrentVersion
136+
137+
if ($currentVersion -like "ShivaayOS - V4*") {
138+
$updates = @("4.1", "4.5")
139+
} elseif ($currentVersion -like "ShivaayOS - V4.1") {
140+
$updates = @("4.5")
141+
} else {
142+
$updates = @()
143+
}
144+
145+
# Change logs for each update
146+
$changeLogs = @{
147+
"4.1" = "Added Feature A.`nImproved Performance."
148+
"4.5" = "Fixed bugs.`nEnhanced UI.`nAdded Feature B."
149+
}
150+
151+
if ($updates.Count -gt 0) {
152+
Update-UI -version $currentVersion -availableUpdates $updates -changeLogs $changeLogs
153+
} else {
154+
[System.Windows.Forms.MessageBox]::Show("No available updates for your version.", "No Updates")
155+
}

ventoy/autounattend.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,8 +1309,8 @@ reg add "HKLM\SOFTWARE\Microsoft\OEM\Device\Capture" /v "NoPhysicalCameraLED" /t
13091309
reg add "HKLM\SYSTEM\CurrentControlSet\Control\CrashControl" /v "AutoReboot" /t REG_DWORD /d 0 /f
13101310
13111311
:: Add Shivaay OS in OEM Info
1312-
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v "Model" /t REG_SZ /d "Shivaay OS - V4.1" /f
1313-
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "RegisteredOrganization" /t REG_SZ /d "Shivaay OS - V4.1" /f
1312+
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v "Model" /t REG_SZ /d "ShivaayOS - V4.1" /f
1313+
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "RegisteredOrganization" /t REG_SZ /d "ShivaayOS - V4.1" /f
13141314
13151315
:: Disable Multi-Plane Overlay (MPO) (Fixes Lags or Glitches On Nvidia or AMD GPUs)
13161316
reg add "HKLM\SOFTWARE\Microsoft\Windows\Dwm" /v OverlayTestMode /t REG_DWORD /d 5 /f

0 commit comments

Comments
 (0)