diff --git a/.gitignore b/.gitignore index 410546d..b5c8693 100644 --- a/.gitignore +++ b/.gitignore @@ -248,4 +248,5 @@ ModelManifest.xml [Oo]thers/ # Arm Build Files -package.zip \ No newline at end of file +package.zip +ArmPackage.zip \ No newline at end of file diff --git a/ArmBuild.ps1 b/ArmBuild.ps1 index 84f9d16..9c162d6 100644 --- a/ArmBuild.ps1 +++ b/ArmBuild.ps1 @@ -1,41 +1,51 @@ +# ArmBuild.ps1 $ErrorActionPreference = "Stop" $root = Split-Path -Parent $MyInvocation.MyCommand.Path $staging = Join-Path $root "_staging" -$outZip = Join-Path $root "package.zip" +$outZip = Join-Path $root "ArmPackage.zip" +$packageFolderName = "Desktop App Installer" +$destRoot = Join-Path $staging $packageFolderName -function Copy-Binaries-ToRoot($src) +function Copy-Binaries-ToDest($src, $dest) { if (!(Test-Path $src)) { return } Get-ChildItem $src -File | Where-Object { $_.Extension -in ".exe", ".dll" } | ForEach-Object { - Copy-Item $_.FullName $staging -Force + Copy-Item -Path $_.FullName -Destination $dest -Force } } Write-Host "Preparing staging..." -Remove-Item $staging -Recurse -Force -ErrorAction Ignore -New-Item $staging -ItemType Directory | Out-Null +# 清理旧的 staging +if (Test-Path $staging) { Remove-Item $staging -Recurse -Force } +New-Item $destRoot -ItemType Directory | Out-Null # ① 先放 Release -Copy-Binaries-ToRoot (Join-Path $root "Release") +Copy-Binaries-ToDest (Join-Path $root "Release") $destRoot # ② 再放 ARM\Release(覆盖同名) -Copy-Binaries-ToRoot (Join-Path $root "ARM\Release") +Copy-Binaries-ToDest (Join-Path $root "ARM\Release") $destRoot -# ③ shared 全部铺到根目录 +# ③ shared 全部铺到 Desktop App Installer 里 $shared = Join-Path $root "shared" if (Test-Path $shared) { Get-ChildItem $shared -Recurse | ForEach-Object { - $rel = $_.FullName.Substring($shared.Length).TrimStart('\') - $dest = Join-Path $staging $rel + $relativePath = $_.FullName.Substring($shared.Length).TrimStart('\') + $destinationPath = Join-Path $destRoot $relativePath if ($_.PSIsContainer) { - New-Item $dest -ItemType Directory -Force | Out-Null + if (!(Test-Path $destinationPath)) { + New-Item -Path $destinationPath -ItemType Directory | Out-Null + } } else { - Copy-Item $_.FullName $dest -Force + $parentDir = Split-Path $destinationPath -Parent + if (!(Test-Path $parentDir)) { + New-Item -Path $parentDir -ItemType Directory | Out-Null + } + Copy-Item -Path $_.FullName -Destination $destinationPath -Force } } } @@ -43,11 +53,10 @@ if (Test-Path $shared) { Write-Host "Creating ZIP..." if (Test-Path $outZip) { Remove-Item $outZip -Force } -Compress-Archive ` - -Path (Join-Path $staging "*") ` - -DestinationPath $outZip ` - -CompressionLevel Fastest +# 压缩 _staging 下的 Desktop App Installer 文件夹 +Compress-Archive -Path $destRoot -DestinationPath $outZip -CompressionLevel Optimal +# 清理 staging Remove-Item $staging -Recurse -Force Write-Host "Done: $outZip" \ No newline at end of file diff --git a/arm_build.bat b/arm_build.bat index a4f8c2e..1d06ebd 100644 --- a/arm_build.bat +++ b/arm_build.bat @@ -1,4 +1,5 @@ @echo off +cd /d "%~dp0" set SCRIPT_DIR=%~dp0 powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%ArmBuild.ps1" pause \ No newline at end of file diff --git a/shared/ArmInstall.ps1 b/shared/ArmInstall.ps1 deleted file mode 100644 index 646dd84..0000000 --- a/shared/ArmInstall.ps1 +++ /dev/null @@ -1,169 +0,0 @@ -锘#Requires -RunAsAdministrator - -Push-Location $PSScriptRoot -try { - # 璇█妫娴嬪嚱鏁 - function Get-Language { - $lang = [System.Globalization.CultureInfo]::CurrentUICulture.TwoLetterISOLanguageName - if ($lang -eq "zh") { return "zh" } - return "en" - } - - $lang = Get-Language - - # 鏈湴鍖栨秷鎭 - $messages = @{ - en = @{ - title = "Desktop App Installer Setup" - confirm = "Do you want to install Desktop App Installer? (y/n)" - invalid = "Invalid input. Please enter y or n." - cancelled = "Installation cancelled." - arch_error = "Error: Cannot continue installation because the computer's processor architecture is not ARM." - creating_shortcuts = "Creating shortcuts in Start Screen..." - registering = "Registering..." - complete = "Installation complete!" - } - zh = @{ - title = "Desktop App Installer 瀹夎绋嬪簭" - confirm = "鏄惁瀹夎 Desktop App Installer锛(y/n)" - invalid = "鏃犳晥杈撳叆锛岃杈撳叆 y 鎴 n銆" - cancelled = "瀹夎宸插彇娑堛" - arch_error = "閿欒锛氭棤娉曠户缁畨瑁咃紝鍥犱负璁$畻鏈虹殑澶勭悊鍣ㄦ灦鏋勪笉鏄 ARM銆" - creating_shortcuts = "姝e湪鍒涘缓寮濮嬪睆骞曞揩鎹锋柟寮..." - registering = "姝e湪娉ㄥ唽..." - complete = "瀹夎瀹屾垚锛" - } - } - - $msg = $messages[$lang] - - # 鍑芥暟瀹氫箟 - function Create-Shortcut { - param( - [string]$LnkPath, - [string]$TargetPath, - [string]$AppId - ) - $toolShortcutPath = Join-Path $PSScriptRoot "shortcut.exe" - if (-not (Test-Path $toolShortcutPath)) { - throw "Error: cannot find file 'shortcut.exe' in folder '$PSScriptRoot'" - } - & $toolShortcutPath $LnkPath $TargetPath $AppId - return $LASTEXITCODE - } - - function Set-DesktopInit { - param( - [string]$IniPath, - [string]$Section, - [string]$Key, - [string]$Value - ) - $toolDesktopIniPath = Join-Path $PSScriptRoot "desktopini.exe" - if (-not (Test-Path $toolDesktopIniPath)) { - throw "Error: cannot find file 'desktopini.exe' in folder '$PSScriptRoot'" - } - & $toolDesktopIniPath $IniPath $Section $Key $Value - return $LASTEXITCODE - } - - # 妫鏌ュ鐞嗗櫒鏋舵瀯 - if ($env:PROCESSOR_ARCHITECTURE.Trim() -ne "ARM") { - throw $msg.arch_error - } - - # 纭瀹夎 - do { - $response = Read-Host $msg.confirm - $response = $response.ToLower() - if ($response -eq 'y') { - $confirmed = $true - break - } elseif ($response -eq 'n') { - Write-Host $msg.cancelled - exit 0 - } else { - Write-Host $msg.invalid - } - } while ($true) - - # 瀹夎鐩綍鍜屽揩鎹锋柟寮忕洰褰 - $appStartMenuFolder = "Desktop App Installer" - $appPublicStartMenuFolder = [System.IO.Path]::Combine($env:ProgramData, "Microsoft\Windows\Start Menu\Programs") - $startitemfolder = [System.IO.Path]::Combine($appPublicStartMenuFolder, $appStartMenuFolder) - $AppFolder = $PSScriptRoot - - Write-Output $msg.creating_shortcuts - if (-not (Test-Path $startitemfolder)) { - New-Item -ItemType Directory -Path $startitemfolder -Force | Out-Null - } - - $shortcuts = @( - @{ - LnkPath = Join-Path $startitemfolder "App Installer.lnk" - TargetPath = Join-Path $AppFolder "appinstaller.exe" - AppId = "Microsoft.DesktopAppInstaller!App" - }, - @{ - LnkPath = Join-Path $startitemfolder "Settings.lnk" - TargetPath = Join-Path $AppFolder "settings.exe" - AppId = "WindowsModern.PracticalToolsProject!Settings" - }, - @{ - LnkPath = Join-Path $startitemfolder "Package Manager.lnk" - TargetPath = Join-Path $AppFolder "Manager.exe" - AppId = "WindowsModern.PracticalToolsProject!Manager" - }, - @{ - LnkPath = Join-Path $startitemfolder "Update.lnk" - TargetPath = Join-Path $AppFolder "Update.exe" - AppId = "WindowsModern.PracticalToolsProject!Update" - }, - @{ - LnkPath = Join-Path $startitemfolder "Package Reader.lnk" - TargetPath = Join-Path $AppFolder "Reader.exe" - AppId = "WindowsModern.PracticalToolsProject!Reader" - } - ) - - foreach ($item in $shortcuts) { - $exitCode = Create-Shortcut -LnkPath $item.LnkPath -TargetPath $item.TargetPath -AppId $item.AppId - } - - # $desktopini = Join-Path $startitemfolder "desktop.ini" - $desktopini = $startitemfolder - Set-DesktopInit -IniPath $desktopini -Section ".ShellClassInfo" -Key "ConfirmFileOp" -Value 0 - Set-DesktopInit -IniPath $desktopini -Section "LocalizedFileNames" -Key "App Installer.lnk" -Value "@$AppFolder\appinstaller.exe,-300" - Set-DesktopInit -IniPath $desktopini -Section "LocalizedFileNames" -Key "Settings.lnk" -Value "@$AppFolder\settings.exe,-200" - Set-DesktopInit -IniPath $desktopini -Section "LocalizedFileNames" -Key "Update.lnk" -Value "@$AppFolder\reslib.dll,-103" - Set-DesktopInit -IniPath $desktopini -Section "LocalizedFileNames" -Key "Package Manager.lnk" -Value "@$AppFolder\reslib.dll,-228" - Set-DesktopInit -IniPath $desktopini -Section "LocalizedFileNames" -Key "Uninstall.lnk" -Value "@$AppFolder\reslib.dll,-131" - Set-DesktopInit -IniPath $desktopini -Section ".ShellClassInfo" -Key "LocalizedResourceName" -Value "@$AppFolder\appinstaller.exe,-300" - - Write-Output $msg.registering - $reg = [Microsoft.Win32.Registry]::ClassesRoot - $key = $reg.CreateSubKey("Microsoft.DesktopAppInstaller") - $key.SetValue("", "Windows Store App Package") - $key.Close() - $subKey = $reg.CreateSubKey("Microsoft.DesktopAppInstaller\Shell\Open\Command") - $subKey.SetValue("", "`"$AppFolder\appinstaller.exe`" `"%1`"") - $subKey.Close() - $subKey = $reg.CreateSubKey("Microsoft.DesktopAppInstaller\DefaultIcon") - $subKey.SetValue("", "$AppFolder\appinstaller.exe,2") - $subKey.Close() - $subKey = $reg.CreateSubKey("Applications\AppInstaller.exe\DefaultIcon") - $subKey.SetValue("", "$AppFolder\appinstaller.exe,-136") - $subKey.Close() - $subKey = $reg.CreateSubKey(".appx") - $subKey.SetValue("", "Microsoft.DesktopAppInstaller") - $subKey.Close() - $subKey = $reg.CreateSubKey(".appxbundle") - $subKey.SetValue("", "Microsoft.DesktopAppInstaller") - $subKey.Close() - - Write-Output "" - Write-Output $msg.complete - Start-Sleep -Seconds 5 -} finally { - Pop-Location -} \ No newline at end of file diff --git a/shared/ArmInstaller.exe b/shared/ArmInstaller.exe new file mode 100644 index 0000000..f42af7f Binary files /dev/null and b/shared/ArmInstaller.exe differ diff --git a/shared/ArmUninstall.ps1 b/shared/ArmUninstall.ps1 deleted file mode 100644 index a68affe..0000000 --- a/shared/ArmUninstall.ps1 +++ /dev/null @@ -1,153 +0,0 @@ -锘#Requires -RunAsAdministrator - -Push-Location $PSScriptRoot -try { - # 璇█妫娴嬪嚱鏁 - function Get-Language { - $lang = [System.Globalization.CultureInfo]::CurrentUICulture.TwoLetterISOLanguageName - if ($lang -eq "zh") { return "zh" } - return "en" - } - - $lang = Get-Language - - # 鏈湴鍖栨秷鎭 - $messages = @{ - en = @{ - title = "Uninstall Desktop App Installer" - confirm = "Are you sure you want to uninstall Desktop App Installer? (y/n)" - invalid = "Invalid input. Please enter y or n." - removing_start = "Removing Start Menu folder..." - removing_reg = "Removing registry entries..." - removing_dir = "Removing installation directory..." - confirm_dir = "Do you also want to delete the installation directory? (y/n)" - complete = "Uninstallation complete." - error = "Error: " - cancelled = "Uninstall cancelled." - } - zh = @{ - title = "鍗歌浇 Desktop App Installer" - confirm = "纭畾瑕佸嵏杞 Desktop App Installer 鍚楋紵(y/n)" - invalid = "鏃犳晥杈撳叆锛岃杈撳叆 y 鎴 n銆" - removing_start = "姝e湪鍒犻櫎寮濮嬭彍鍗曟枃浠跺す..." - removing_reg = "姝e湪鍒犻櫎娉ㄥ唽琛ㄩ」..." - removing_dir = "姝e湪鍒犻櫎瀹夎鐩綍..." - confirm_dir = "鏄惁鍚屾椂鍒犻櫎瀹夎鐩綍锛(y/n)" - complete = "鍗歌浇瀹屾垚銆" - error = "閿欒锛" - cancelled = "鍗歌浇宸插彇娑堛" - } - } - - $msg = $messages[$lang] - - if ($env:PROCESSOR_ARCHITECTURE.Trim() -ne "ARM") { - throw "Error: Cannot continue installation because the computer's processor architecture is not ARM." - } - - # 纭鍗歌浇锛堟帶鍒跺彴浜や簰锛 - do { - $response = Read-Host $msg.confirm - $response = $response.ToLower() - if ($response -eq 'y') { - $confirmed = $true - break - } elseif ($response -eq 'n') { - Write-Host $msg.cancelled - exit 0 - } else { - Write-Host $msg.invalid - } - } while ($true) - - # 瀹氫箟璺緞 - $appStartMenuFolder = "Desktop App Installer" - $appPublicStartMenuFolder = [System.IO.Path]::Combine($env:ProgramData, "Microsoft\Windows\Start Menu\Programs") - $startitemfolder = [System.IO.Path]::Combine($appPublicStartMenuFolder, $appStartMenuFolder) - $AppFolder = $PSScriptRoot - - # 鍒犻櫎寮濮嬭彍鍗曟枃浠跺す - Write-Host $msg.removing_start - if (Test-Path $startitemfolder) { - Remove-Item -Path $startitemfolder -Recurse -Force -ErrorAction SilentlyContinue - if (Test-Path $startitemfolder) { - Write-Warning "$msg.error Could not remove $startitemfolder" - } else { - Write-Output "Removed $startitemfolder" - } - } else { - Write-Output "Start Menu folder not found, skipping." - } - - # 鍒犻櫎娉ㄥ唽琛ㄩ」 - Write-Host $msg.removing_reg - $reg = [Microsoft.Win32.Registry]::ClassesRoot - - $keysToDelete = @( - "Microsoft.DesktopAppInstaller", - ".appx", - ".appxbundle" - ) - foreach ($keyName in $keysToDelete) { - try { - if ($reg.OpenSubKey($keyName) -ne $null) { - $reg.DeleteSubKeyTree($keyName) - Write-Output "Removed registry key: HKCR\$keyName" - } else { - Write-Output "Registry key not found: HKCR\$keyName" - } - } catch { - Write-Warning "$msg.error Could not remove HKCR\$keyName : $_" - } - } - - # 鍒犻櫎 Applications\AppInstaller.exe 涓嬬殑 DefaultIcon - $appPath = "Applications\AppInstaller.exe" - try { - $appKey = $reg.OpenSubKey($appPath, $true) - if ($appKey) { - $subKeyNames = $appKey.GetSubKeyNames() - if ($subKeyNames -contains "DefaultIcon") { - $appKey.DeleteSubKey("DefaultIcon") - Write-Output "Removed registry key: HKCR\$appPath\DefaultIcon" - } - $appKey.Close() - } else { - Write-Output "Registry key not found: HKCR\$appPath" - } - } catch { - Write-Warning "$msg.error Could not process HKCR\$appPath : $_" - } - - # 鍒犻櫎瀹夎鐩綍 - Write-Host $msg.removing_dir - do { - $respDir = Read-Host $msg.confirm_dir - $respDir = $respDir.ToLower() - if ($respDir -eq 'y') { - if (Test-Path $AppFolder) { - Remove-Item -Path $AppFolder -Recurse -Force -ErrorAction SilentlyContinue - if (Test-Path $AppFolder) { - Write-Warning "$msg.error Could not delete $AppFolder" - } else { - Write-Output "Deleted installation directory." - } - } else { - Write-Output "Installation directory not found." - } - break - } elseif ($respDir -eq 'n') { - Write-Output "Skipped deleting installation directory." - break - } else { - Write-Host $msg.invalid - } - } while ($true) - - Write-Host $msg.complete - Start-Sleep -Seconds 3 -} catch { - Write-Error "Uninstall failed: $_" -} finally { - Pop-Location -} \ No newline at end of file diff --git a/shared/ArmUninstaller.exe b/shared/ArmUninstaller.exe new file mode 100644 index 0000000..86af80e Binary files /dev/null and b/shared/ArmUninstaller.exe differ diff --git a/shared/arm_install.bat b/shared/arm_install.bat deleted file mode 100644 index 9824460..0000000 --- a/shared/arm_install.bat +++ /dev/null @@ -1,13 +0,0 @@ -@echo off -if exist "%SystemRoot%\SysWOW64" path %path%;%windir%\SysNative;%SystemRoot%\SysWOW64;%~dp0 -bcdedit >nul -if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto UACAdmin) -:UACPrompt -%1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&exit -exit /B -:UACAdmin -cd /d "%~dp0" - -set SCRIPT_DIR=%~dp0 -powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%ArmInstall.ps1" -pause \ No newline at end of file diff --git a/shared/arm_readme.txt b/shared/arm_readme.txt index 10384b1..c784c9e 100644 --- a/shared/arm_readme.txt +++ b/shared/arm_readme.txt @@ -1,11 +1,11 @@ -瀵逛簬 Windows RT 鐢ㄦ埛锛岃浠ョ鐞嗗憳韬唤杩愯 arm_install.bat 鎴 arm_uninstall.bat 杩涜瀹夎鎴栧嵏杞姐傚畨瑁呭墠璇峰姟蹇呭皢鍘嬬缉鍖呬腑鐨勬墍鏈夋枃浠舵斁缃湪涓涓嫭绔嬬殑鏂囦欢澶逛腑锛岃鏂囦欢澶硅鍕块殢鎰忕Щ鍔ㄦ垨鍒犻櫎锛屼笉寤鸿鏀剧疆鍦ㄦ闈笂銆傝嫢闇鏇存柊鎴栫Щ鍔ㄧ▼搴忥紝璇峰厛鎵ц鍘熷嵏杞借剼鏈紝鐒跺悗鍐嶈繘琛屽畨瑁呮搷浣溿倄86銆亁64 浠ュ強鏀寔 x86 鍏煎灞傜殑 ARM64 绯荤粺璇蜂娇鐢ㄦ爣鍑嗗畨瑁呯▼搴忥紝鏈柟妗堜粎閫傜敤浜 ARM 璁惧銆 +瀵逛簬 Windows RT 鐢ㄦ埛锛岃浠ョ鐞嗗憳韬唤杩愯 ArmInstaller.exe 鎴 ArmUninstaller.exe 杩涜瀹夎鎴栧嵏杞姐傚畨瑁呭墠璇峰姟蹇呭皢鍘嬬缉鍖呬腑鐨勬墍鏈夋枃浠舵斁缃湪涓涓嫭绔嬬殑鏂囦欢澶逛腑锛岃鏂囦欢澶硅鍕块殢鎰忕Щ鍔ㄦ垨鍒犻櫎锛屼笉寤鸿鏀剧疆鍦ㄦ闈笂銆傝嫢闇鏇存柊鎴栫Щ鍔ㄧ▼搴忥紝璇峰厛鎵ц鍗歌浇绋嬪簭锛岀劧鍚庡啀杩涜瀹夎鎿嶄綔銆傝涓嶈浣跨敤绋嬪簭涓叿鏈夌殑瀹夎绋嬪簭鏉ユ洿鏂般 x86銆亁64 浠ュ強 鍏锋湁 Windows on ARM 鐨 ARM64 绯荤粺 璇蜂娇鐢ㄦ爣鍑嗗畨瑁呯▼搴忥紝鏈柟妗堜粎閫傜敤浜 ARM 璁惧銆 鎰熻阿鈥滃啺绯朮H鈥濓紙涓婚〉锛歨ttps://github.com/bingtangxh锛夊府鍔╂垜瀹屾垚浜嗛拡瀵 ARM 鏋舵瀯鐨勭▼搴忕紪璇戙 閫傜敤浜 ARM 璁惧鐨勯」鐩彂琛岋細https://github.com/bingtangxh/App-Installer-For-Windows-8.x-Reset/releases 鍏朵綑璁惧鐨勯」鐩彂琛岋細https://github.com/modernw/App-Installer-For-Windows-8.x-Reset/releases (Translated by DeepSeek) -For Windows RT users, please run arm_install.bat or arm_uninstall.bat as an administrator to install or uninstall. Before installation, extract all files from the compressed package into a dedicated folder; do not move or delete this folder arbitrarily, and it is not recommended to place it on the desktop. If you need to update or relocate the program, first run the original uninstall script, then proceed with the installation. For x86, x64, and ARM64 systems that support the x86 compatibility layer, please use the standard installer; this solution is specifically for ARM devices. +For Windows RT users, please run ArmInstaller.exe or ArmUninstaller.exe as an administrator to install or uninstall. Before installation, extract all files from the compressed package into a dedicated folder; do not move or delete this folder arbitrarily, and it is not recommended to place it on the desktop. If you need to update or relocate the program, first run the uninstaller, then proceed with the installation. Do not use the installer included in the program to update. For x86, x64, and ARM64 systems with Windows on ARM please use the standard installer; this solution is specifically for ARM devices. Thanks to "BingTangXH" (Homepage: https://github.com/bingtangxh) for helping me complete the program compilation for the ARM architecture. Project release for ARM devices: https://github.com/bingtangxh/App-Installer-For-Windows-8.x-Reset/releases diff --git a/shared/arm_uninstall.bat b/shared/arm_uninstall.bat deleted file mode 100644 index 9d839d1..0000000 --- a/shared/arm_uninstall.bat +++ /dev/null @@ -1,13 +0,0 @@ -@echo off -if exist "%SystemRoot%\SysWOW64" path %path%;%windir%\SysNative;%SystemRoot%\SysWOW64;%~dp0 -bcdedit >nul -if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto UACAdmin) -:UACPrompt -%1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&exit -exit /B -:UACAdmin -cd /d "%~dp0" - -set SCRIPT_DIR=%~dp0 -powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%ArmUninstall.ps1" -pause \ No newline at end of file