|
本帖最后由 hlowld 于 2025-7-3 19:24 编辑
对离线镜像(假设在z:)执行以下代码,安装后,所有用户都不会有白名单以外的APPX(包括Defender等NonRemovable为True的系统应用)
偶然发现插入代码好像要吃字符,导致脚本无效,改为直接发文本。
:removeproappx
powershell -NoProfile -Command ^
"Get-ProvisionedAppxPackage -Path 'z:' |" ^
"Where-Object { " ^
" $_.DisplayName -notmatch 'ShellExperienceHost|StartMenuExperienceHost|Client\.CBS|immersivecontrolpanel|PrintDialog|VCLibs'" ^
"} |" ^
"Remove-ProvisionedAppxPackage -Path 'z:'" >nul 2>nul
reg load HKLM\sof z:\Windows\System32\config\software >nul 2>nul || goto :eof
set "exclude_list=ShellExperienceHost StartMenuExperienceHost Client.CBS immersivecontrolpanel PrintDialog VCLibs"
for /f "tokens=9 delims=\" %%a in ('reg query "HKLM\sof\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\InboxApplications"') do (
set "should_delete=1"
for %%# in (%exclude_list%) do (echo %%a | findstr /i "%%#" >nul && set "should_delete=0")
if "!should_delete!" equ "1" reg delete "HKLM\sof\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\InboxApplications\%%a" /f >nul 2>nul
)
reg unload HKLM\sof >nul 2>nul
goto :eof
对于Edge,在线系统用老版本安装包执行卸载,暂时没找到简单好用的离线卸载方法。不太愿意用删除注册表和文件的方案,感觉容易出错,对系统版本的兼容性也不高。
:removeedge
if exist "%~dp0edgesetup.exe" (
for /f "tokens=1 delims=\" %%i in ('dir /B /A:D "%ProgramFiles(x86)%\Microsoft\Edge\Application" 2^>nul ^| find "."') do set "edge_chromium_package_version=%%i"
if defined edge_chromium_package_version (
taskkill /f /im msedge.exe >nul 2>nul
taskkill /f /im MicrosoftEdgeUpdate.exe >nul 2>nul
%~dp0edgesetup.exe --uninstall --force-uninstall --msedge --system-level --verbose-logging
)
)
del /f /q "%USERPROFILE%\Desktop\Microsoft Edge.lnk" >nul 2>nul
del /f /q "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk" >nul 2>nul
del /f /q "%appdata%\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk" >nul 2>nul
goto :eof
|
评分
-
查看全部评分
|