1- # Variables
2- $apiUrl = " https://api.github.com/repos/ShivamXD6/Optimize-Windows/releases"
3- $customPath = " HKLM:\Software\ShivaayOS"
4- if (Test-Path $customPath ) {
5- $shivaayPath = (Get-ItemProperty - Path $customPath - Name " ShivaayFolderPath" )." ShivaayFolderPath"
6- } else {
7- $shivaayPath = " $desktopPath \Shivaay"
8- }
9-
10- # Functions
111# Function to get the current version from the OEM information
122function Get-CurrentVersion {
133 $oemInfo = Get-ItemProperty " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation"
144
15- if ($oemInfo.Model -match " ShivaayOS - V(\d+(\.\d+)?)" ) {
16- return $matches [1 ]
17- }
18- return " 0.0"
5+ # Extract the model name and version using regex
6+ if ($oemInfo.Model -match " (.*) - V(\d+(\.\d+)?)" ) {
7+ $modelName = $matches [1 ] # The part before " - V"
8+ $version = $matches [2 ] # The version after "V"
9+ return @ { ModelName = $modelName ; Version = $version }
10+ }
11+ return @ { ModelName = " Unknown" ; Version = " 0.0" } # Default if no match is found
1912}
2013
21- $currentVersion = Get-CurrentVersion
14+ # Function to update OEM information
15+ function Update-OEMInfo {
16+ param (
17+ [string ]$newVersion ,
18+ [string ]$modelName
19+ )
20+ # Update the model string with the new version but keep the model name
21+ $newModelString = " $modelName - V$newVersion "
22+ reg add " HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" / v " Model" / t REG_SZ / d $newModelString / f
23+ Write-Host " "
24+ Write-Host " Updated to $newModelString ." - ForegroundColor Green
25+ Write-Host " "
26+ Write-Host " Press Enter to Check for more updates..." - ForegroundColor Cyan
27+ Write-Host " "
28+ }
2229
2330# Function to display a decorated header
2431function Show-Header {
@@ -95,24 +102,79 @@ function Get-NextVersions {
95102 return $nextVersions
96103}
97104
98- # Function to update OEM information
99- function Update-OEMInfo {
105+ # Function to Show Update Process
106+ function Dis {
100107 param (
101- [string ]$version
108+ [string ]$txt = " Updating"
109+ )
110+ Write-Host " "
111+ Write-Host " - $txt "
112+ Start-Sleep - Milliseconds 100
113+ }
114+
115+ # Function to Create Files
116+ function Create-File {
117+ param (
118+ [string ]$fileContent ,
119+ [string ]$fileName ,
120+ [string ]$fileDirectory
102121 )
103- reg add " HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation " / v " Model " / t REG_SZ / d " ShivaayOS - V $version " / f
104- Write-Host " Updated to ShivaayOS - V $version . " - ForegroundColor Green
122+ $outputFilePath = [ System.IO.Path ]::Combine( $fileDirectory , " $fileName " )
123+ $fileContent | Out-File - FilePath $outputFilePath - Encoding ASCII
105124}
106125
126+ # Function to Create Shortcuts
127+ function Create-Shortcut {
128+ param (
129+ [string ]$target ,
130+ [string ]$shortcutName ,
131+ [string ]$shortcutType ,
132+ [string ]$shortcutPath = $shivaayPath
133+ )
134+ $shell = New-Object - ComObject WScript.Shell
135+ $fullPath = Join-Path $shortcutPath $shortcutName
136+ $softPath = Join-Path $softwaresPath $shortcutName
137+ if ($shortcutType -eq " url" ) {
138+ $internetShortcut = $shell.CreateShortcut ($softPath )
139+ $internetShortcut.TargetPath = $target
140+ $internetShortcut.Save ()
141+ } else {
142+ $shortcut = $shell.CreateShortcut ($fullPath )
143+ $shortcut.TargetPath = " powershell.exe"
144+ $shortcut.Arguments = " -NoProfile -ExecutionPolicy RemoteSigned -Command `" $target `" "
145+ $shortcut.Save ()
146+ }
147+ }
148+
149+ # Variables
150+ $apiUrl = " https://api.github.com/repos/ShivamXD6/Optimize-Windows/releases"
151+ $customPath = " HKLM:\Software\ShivaayOS"
152+ if (Test-Path $customPath ) {
153+ $global :shivaayPath = (Get-ItemProperty - Path $customPath - Name " ShivaayFolderPath" )." ShivaayFolderPath"
154+ } else {
155+ $global :shivaayPath = " $desktopPath \Shivaay"
156+ }
157+ $global :desktopPath = " C:\Users\Public\Desktop"
158+ $global :optimizationPath = " $shivaayPath \Optimizations"
159+ $global :securityPath = " $shivaayPath \Security"
160+ $global :softwaresPath = " $shivaayPath \Softwares"
161+ $global :managementPath = " $shivaayPath \System Management"
162+ $global :interfacePath = " $shivaayPath \User Interface"
163+
107164# Main script execution
108165Show-Header " Checking for Updates"
109166$releases = Fetch- Releases
110167
168+ # Get the current model name and version
169+ $currentInfo = Get-CurrentVersion
170+ $currentModelName = $currentInfo.ModelName
171+ $currentVersion = $currentInfo.Version
172+
111173# Get the next versions to update to
112174$nextVersions = Get-NextVersions - currentVersion $currentVersion - releases $releases
113175
114176if ($nextVersions.Count -gt 0 ) {
115- Write-Host " Current version: $currentVersion " - ForegroundColor Yellow
177+ Write-Host " Current model: $currentModelName - V $currentVersion " - ForegroundColor Yellow
116178 Write-Host " Available versions to update: $ ( $nextVersions -join ' , ' ) " - ForegroundColor Yellow
117179 Write-Host " "
118180
@@ -140,8 +202,9 @@ if ($nextVersions.Count -gt 0) {
140202 $scriptUrl = $updateAsset.browser_download_url
141203 Write-Host " Executing script from: $scriptUrl " - ForegroundColor Green
142204 try {
143- irm $scriptUrl | iex
144- Update-OEMInfo - version $nextVersion
205+ irm $scriptUrl | iex 2> $null
206+ # Update the OEM info with the new version, preserving the model name
207+ Update-OEMInfo - newVersion $nextVersion - modelName $currentModelName
145208 pause
146209 } catch {
147210 Write-Host " Failed to execute the script from $scriptUrl ." - ForegroundColor Red
@@ -153,8 +216,10 @@ if ($nextVersions.Count -gt 0) {
153216 }
154217 }
155218} else {
156- Write-Host " You are already on the latest version: $currentVersion " - ForegroundColor Green
219+ Write-Host " You are already using the latest version: $currentVersion " - ForegroundColor Green
157220 pause
158221}
159-
160- Write-Host " Updates completed!" - ForegroundColor Cyan
222+ Write-Host " "
223+ Write-Host " All Updates completed!, no more updates are available!" - ForegroundColor Green
224+ Write-Host " "
225+ pause
0 commit comments