Hi guys! In my SetupComplete.cmd I've written: ECHO PowerShell "Get-AppxPackage Microsoft.BingNews | Remove-AppxPackage">>"Windows 11 Pro.cmd" REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v "Windows 11 Pro" /t REG_SZ /d "CMD /C \"%CD%\Windows 11 Pro.cmd\"" /f So, at the first Windows login a command prompt runs the uninstallation of a provisioned app. The problem is that after app deletion Windows restores it. Do you have some solution to definitely remove provisioned apps using SetupComplete.cmd? Thank you in advance for your support!
it never restore for me, did you verify it remove it ? I do suggest to remove all this s**t* app from system level too - to all users. you can use something like this. Code: @cls @echo off >nul chcp 437 cd /d "%~dp0" :: Bigger list ….. you can use this set "Apps=Getstarted,549981C3F5F10,Recorder,Alarms,Phone,Films,Music,People,Automate,Sketch,XBox,Maps,3D,Wallet,Weather,Reality,onenote,Bing,Zune,Notes,Todo,OfficeHub,Tips,clipchamp,Family,QuickAssist" rem Run as administrator, AveYo: ps\VBS version >nul fltmc || ( set "_=call "%~dpfx0" %*" powershell -nop -c start cmd -args '/d/x/r',$env:_ -verb runas || ( mshta vbscript:execute^("createobject(""shell.application"").shellexecute(""cmd"",""/d/x/r "" &createobject(""WScript.Shell"").Environment(""PROCESS"")(""_""),,""runas"",1)(window.close)"^))|| ( cls & echo:& echo Script elavation failed& pause) exit ) >nul 2>&1 where powershell || ( echo. echo Missing Critical files [powershell.exe] echo. pause exit /b ) whoami|>nul findstr /i /c:"nt authority\system" && ( call :RunAtSystemLevel exit ) echo == Remove UWP Apps for %%# in (%Apps%) do ( >nul powershell -noprofile -executionpolicy bypass -command "Get-AppxPackage -Name *%%#* | Foreach {Remove-AppxPackage $_.PackageFullName}" >nul powershell -noprofile -executionpolicy bypass -command "Get-ProvisionedAppxPackage -Online | Where-Object { $_.PackageName -match '%%#' } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -PackageName $_.PackageName }" ) call :RunAsTI "%~dpfx0" timeout 10 exit :RunAtSystemLevel :RunAtSystemLevel :RunAtSystemLevel echo == Remove UWP Apps for %%# in (%Apps%) do ( >nul powershell -noprofile -executionpolicy bypass -command "Get-AppxPackage -Name *%%#* -AllUsers | Foreach {Remove-AppxPackage $_.PackageFullName -AllUsers}" >nul powershell -noprofile -executionpolicy bypass -command "Get-ProvisionedAppxPackage -Online | Where-Object { $_.PackageName -match '%%#' } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName }" ) goto :eof :: AveYo's Helpers :: AveYo's Helpers :: AveYo's Helpers :export #:RunAsTI: #1 snippet to run as TI/System, with /high priority, /priv ownership, explorer and HKCU load set ^ #=& set "0=%~f0"& set 1=%*& powershell -nop -c iex(([io.file]::ReadAllText($env:0)-split':RunAsTI\:.*')[1])& exit/b $_CAN_PASTE_DIRECTLY_IN_POWERSHELL='^,^'; function RunAsTI ($cmd) { $id='RunAsTI'; $sid=((whoami /user)-split' ')[-1]; $code=@' $ti=(whoami /groups)-like"*1-16-16384*"; $DM=[AppDomain]::CurrentDomain."DefineDynamicAss`embly"(1,1)."DefineDynamicMod`ule"(1) $D=@(); 0..5|% {$D+=$DM."DefineT`ype"("M$_",1179913,[ValueType])}; $I=[int32];$P=$I.module.gettype("System.Int`Ptr"); $U=[uintptr] $D+=$U; 4..6|% {$D+=$D[$_]."MakeB`yRefType"()};$M=$I.module.gettype("System.Runtime.Interop`Services.Mar`shal");$Z=[uintptr]::size $S=[string]; $F="kernel","advapi","advapi",($S,$S,$I,$I,$I,$I,$I,$S,$D[7],$D[8]),($U,$S,$I,$I,$D[9]),($U,$S,$I,$I,[byte[]],$I) 0..2|% {$9=$D[0]."DefinePInvokeMeth`od"(("CreateProcess","RegOpenKeyEx","RegSetValueEx")[$_],$F[$_]+'32',8214,1,$S,$F[$_+3],1,4)} $DF=0,($P,$I,$P),($I,$I,$I,$I,$P,$D[1]),($I,$S,$S,$S,$I,$I,$I,$I,$I,$I,$I,$I,[int16],[int16],$P,$P,$P,$P),($D[3],$P),($P,$P,$I,$I) 1..5|% {$k=$_;$n=1;$AveYo=1; $DF[$_]|% {$9=$D[$k]."DefineFie`ld"('f'+$n++,$_,6)}}; $T=@(); 0..5|% {$T+=$D[$_]."CreateT`ype"()} 0..5|% {nv "A$_" ([Activator]::CreateInstance($T[$_])) -force}; function F ($1,$2) {$T[0]."GetMeth`od"($1).invoke(0,$2)}; if (!$ti) { $g=0; "TrustedInstaller","lsass"|% {if (!$g) {net1 start $_ 2>&1 >$null; $g=@(get-process -name $_ -ea 0|% {$_})[0]}} function M($1,$2,$3){$M."GetMeth`od"($1,[type[]]$2).invoke(0,$3)}; $H=@(); $Z,(4*$Z+16)|% {$H+=M "AllocHG`lobal" $I $_}; M "WriteInt`Ptr" ($P,$P) ($H[0],$g.Handle); $A1.f1=131072;$A1.f2=$Z;$A1.f3=$H[0];$A2.f1=1;$A2.f2=1;$A2.f3=1;$A2.f4=1;$A2.f6=$A1 $A3.f1=10*$Z+32;$A4.f1=$A3;$A4.f2=$H[1]; M "StructureTo`Ptr" ($D[2],$P,[boolean]) (($A2 -as $D[2]),$A4.f2,$false); $w=0x0E080600 $out=@($null,"powershell -win 1 -nop -c iex `$env:A",0,0,0,$w,0,$null,($A4 -as $T[4]),($A5 -as $T[5])); F "CreateProcess" $out } else { $env:A=''; $PRIV=[uri].module.gettype("System.Diagnostics.Process")."GetMeth`ods"(42) |? {$_.Name -eq "SetPrivilege"} "SeSecurityPrivilege","SeTakeOwnershipPrivilege","SeBackupPrivilege","SeRestorePrivilege" |% {$PRIV.Invoke(0, @("$_",2))} $HKU=[uintptr][uint32]2147483651; $LNK=$HKU; $reg=@($HKU,"S-1-5-18",8,2,($LNK -as $D[9])); F "RegOpenKeyEx" $reg; $LNK=$reg[4] function SYM($1,$2){$b=[Text.Encoding]::Unicode.GetBytes("\Registry\User\$1");@($2,"SymbolicLinkValue",0,6,[byte[]]$b,$b.Length)} F "RegSetValueEx" (SYM $(($key-split'\\')[1]) $LNK); $EXP="HKLM:\Software\Classes\AppID\{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}" $r="explorer"; if (!$cmd) {$cmd='C:\'}; $dir=test-path -lit ((($cmd -split '^("[^"]+")|^([^\s]+)') -ne'')[0].trim('"')) -type 1 if (!$dir) {$r="start `"$id`" /high /w"}; sp $EXP RunAs '' -force; start cmd -args ("/q/x/d/r title $id && $r",$cmd) -wait -win 1 do {sleep 7} while ((gwmi win32_process -filter 'name="explorer.exe"'|? {$_.getownersid().sid -eq "S-1-5-18"})) F "RegSetValueEx" (SYM ".Default" $LNK); sp $EXP RunAs "Interactive User" -force } # lean and mean snippet by AveYo, 2018-2021 '@; $key="Registry::HKEY_USERS\$sid\Volatile Environment"; $a1="`$id='$id';`$key='$key';";$a2="`$cmd='$($cmd-replace"'","''")';`n" sp $key $id $($a1,$a2,$code) -type 7 -force; $arg="$a1 `$env:A=(gi `$key).getvalue(`$id)-join'';rp `$key `$id -force; iex `$env:A" $_PRESS_ENTER='^,^'; start powershell -args "-win 1 -nop -c $arg" -verb runas }; <#,#> RunAsTI $env:1; #:RunAsTI:
Code: @echo off SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION color 0A title Win ISO Debloater echo ***************************************************************** echo ------------------- Ensure Admin Privileges --------------------- echo ***************************************************************** REM --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( echo Requesting administrative privileges... goto UACPrompt) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" exit /B :gotAdmin echo ***************************************************************** echo. cd %~dp0 IF NOT EXIST "mount" md "mount" echo. echo ***************************************************************** echo --- Export Windows 10 Single Index of Your Choice to Script Path echo ***************************************************************** SET /A count=0 FOR /F "tokens=2 delims=: " %%i IN ('DISM /Get-WimInfo /WimFile:"DVD\sources\install.wim" ^| findstr "Index"') DO SET images=%%i FOR /L %%i in (1, 1, %images%) DO CALL :CountIndex %%i echo. Wim Image contain following %images% indexes : echo. FOR /L %%i in (1, 1, %images%) DO ( echo. [%%i] !name%%i! ) GOTO ExportIndex echo ***************************************************************** :MOVE echo ***************************************************************** echo --- Move Back Exported WIM Image to its Source Path echo ***************************************************************** move /y "install.wim" "DVD\sources\install.wim" echo ***************************************************************** echo. echo ***************************************************************** echo --- Mounting Selected Windows 10 WIM image to Mount Directory echo ***************************************************************** dism /mount-wim /wimfile:DVD\sources\install.wim /index:1 /mountdir:mount echo ***************************************************************** echo. echo ***************************************************************** echo --- Remove OneDrive From Offline Image echo ***************************************************************** Bin\tweaker /p mount /c Microsoft-Windows-OneDrive /r echo.***************************************************************** echo. echo ***************************************************************** echo.--- Disable Tamper Protection echo ***************************************************************** reg load "HKLM\OfflineSOFTWARE" "mount\Windows\System32\config\SOFTWARE" Bin\SetACL -on "HKLM\OfflineSOFTWARE\Microsoft\Windows Defender\Features" -ot reg -actn setowner -ownr "n:Administrators" Bin\SetACL -on "HKLM\OfflineSOFTWARE\Microsoft\Windows Defender\Features" -ot reg -actn ace -ace "n:Administrators;p:full" Powershell -Command "Get-Item -Path 'HKLM:OfflineSOFTWARE\Microsoft\Windows Defender\Features' | New-ItemProperty -Name TamperProtection -Value 4 -PropertyType DWord -Verbose" Powershell -Command "Get-Item -Path 'HKLM:OfflineSOFTWARE\Microsoft\Windows Defender\Features' | New-ItemProperty -Name TamperProtectionSource -Value 2 -PropertyType DWord -Verbose" reg unload "HKLM\OfflineSOFTWARE" echo ***************************************************************** echo. echo ***************************************************************** echo --- Remove Windows Apps echo ***************************************************************** for %%p in ( Microsoft.549981C3F5F10 Microsoft.BingWeather Microsoft.DesktopAppInstaller Microsoft.GetHelp Microsoft.Getstarted Microsoft.HEIFImageExtension Microsoft.Microsoft3DViewer Microsoft.MicrosoftOfficeHub Microsoft.MicrosoftSolitaireCollection Microsoft.MicrosoftStickyNotes Microsoft.MixedReality.Portal Microsoft.MSPaint Microsoft.Office.OneNote Microsoft.People Microsoft.ScreenSketch Microsoft.SkypeApp Microsoft.StorePurchaseApp Microsoft.VCLibs.140.00 Microsoft.VP9VideoExtensions Microsoft.Wallet Microsoft.WebMediaExtensions Microsoft.WebpImageExtension Microsoft.Windows.Photos Microsoft.WindowsAlarms Microsoft.WindowsCalculator Microsoft.WindowsCamera Microsoft.windowscommunicationsapps Microsoft.WindowsFeedbackHub Microsoft.WindowsMaps Microsoft.WindowsSoundRecorder Microsoft.WindowsStore Microsoft.Xbox.TCUI Microsoft.XboxApp Microsoft.XboxGameOverlay Microsoft.XboxGamingOverlay Microsoft.XboxIdentityProvider Microsoft.XboxSpeechToTextOverlay Microsoft.YourPhone Microsoft.ZuneMusic Microsoft.ZuneVideo ) do ( Powershell -C "Write-Host 'Removing Windows App: %%p'" Powershell -C "Get-AppxProvisionedPackage -Path mount | Where {$_.DisplayName -match '%%p' } | Remove-AppxProvisionedPackage -Path mount -EA ignore" ) echo ***************************************************************** echo. echo ***************************************************************** echo --- Disable UnNeeded Windows Features echo ***************************************************************** for %%p in ( Printing-PrintToPDFServices-Features Windows-Defender-Default-Definitions Printing-XPSServices-Features MSRDC-Infrastructure WorkFolders-Client Printing-Foundation-Features Printing-Foundation-InternetPrinting-Client MicrosoftWindowsPowerShellV2Root MicrosoftWindowsPowerShellV2 WCF-Services45 WCF-TCP-PortSharing45 SMB1Protocol SMB1Protocol-Client SMB1Protocol-Deprecation MediaPlayback WindowsMediaPlayer Internet-Explorer-Optional-amd64 ) do ( Powershell -C "Write-Host 'Disabling Windows Optional Feature: %%p'" Powershell -C "Get-WindowsOptionalFeature -Path 'mount' | Where {$_.FeatureName -match '%%p' } | Disable-WindowsOptionalFeature -Path 'mount' -EA ignore" ) echo ***************************************************************** echo. echo ***************************************************************** echo --- Remove UnNeeded Windows Capabilities echo ***************************************************************** for %%p in ( App.StepsRecorder~~~~0.0.1.0 App.Support.QuickAssist~~~~0.0.1.0 Browser.InternetExplorer~~~~0.0.11.0 DirectX.Configuration.Database~~~~0.0.1.0 Hello.Face.18967~~~~0.0.1.0 Hello.Face.Migration.18967~~~~0.0.1.0 Language.Handwriting~~~en-US~0.0.1.0 Language.OCR~~~en-US~0.0.1.0 Language.Speech~~~en-US~0.0.1.0 Language.TextToSpeech~~~en-US~0.0.1.0 MathRecognizer~~~~0.0.1.0 OneCoreUAP.OneSync~~~~0.0.1.0 OpenSSH.Client~~~~0.0.1.0 Print.Fax.Scan~~~~0.0.1.0 Windows.Client.ShellComponents~~~~0.0.1.0 ) do ( Powershell -C "Write-Host 'Removing Windows Capability: %%p'" Powershell -Command "Get-WindowsCapability -Path 'mount' | Where {$_.Name -match '%%p' } | Remove-WindowsCapability -Path 'mount' -EA ignore" ) echo ***************************************************************** echo. echo ***************************************************************** echo --- Saving and Unmounting Final Image echo ***************************************************************** dism /unmount-wim /mountdir:mount /commit echo ***************************************************************** echo. echo ***************************************************************** echo --- Export Install Wim to Compress Maximum echo ***************************************************************** dism /Export-Image /SourceImageFile:DVD\sources\install.wim /All /DestinationImageFile:install.wim /Compress:Max /CheckIntegrity move /y "install.wim" "DVD\sources\install.wim" echo ***************************************************************** echo. echo ***************************************************************** echo --- Add autounattend.xml , $OEM$ to iso if Exist Next to Script echo ***************************************************************** echo --- Add AutoUnattend.xml to Root of ISO If Present IF EXIST "AutoUnattend.xml" copy "AutoUnattend.xml" "DVD\AutoUnattend.xml" /v /y echo. echo --- Add $OEM$ Pack to ISO Sources If Present IF EXIST "$OEM$" XCOPY "$OEM$" "DVD\sources\$OEM$" /E /I /Y echo ***************************************************************** echo. echo ***************************************************************** echo --- Create Final Win10 Tweaked ISO echo ***************************************************************** "Bin\oscdimg.exe" -bootdata:2#p0,e,b".\DVD\boot\etfsboot.com"#pEF,e,b".\DVD\efi\microsoft\boot\efisys.bin" -o -h -m -u2 -udfver102 -lCCSA_X64FRE_EN-US_DV9 ".\DVD" "%~dp0Windows.iso" echo ***************************************************************** echo. echo ***************************************************************** echo --- Remove Extra Files of Project %Ver% echo ***************************************************************** cd %~dp0 Powershell -Command "Clear-WindowsCorruptMountPoint" IF EXIST "DVD" rd /s /q "DVD" IF EXIST "mount" rd /s /q "mount" IF EXIST "SOFTWAREBKP" del /f /q "SOFTWAREBKP" echo ***************************************************************** echo **************************** The End **************************** pause exit /b :ExportIndex echo. SET /P INDEXCHOICE=Select Single Image Index Number You Want to Export and Tweak : DISM /Export-Image /SourceImageFile:"DVD\sources\install.wim" /Sourceindex:%INDEXCHOICE% /DestinationImageFile:"%~dp0\install.wim" /CheckIntegrity echo ***************************************************************** echo. GOTO MOVE :CountIndex SET /A count+=1 FOR /f "tokens=1* delims=: " %%i IN ('DISM /Get-WimInfo /wimfile:"DVD\sources\install.wim" /index:%1 ^| find /i "Name"') DO SET name%count%=%%j
Great! How could I insert comments / escape lines inside: for %%p in ( Microsoft.549981C3F5F10 ... REM Microsoft.YourPhone) ? Because "REM" or "::" don't work. Thank you guys!
Pl remove app name from script you dont want to remove from offline image. same goes for optional features as well as capabilities. if you want to add more app names just add in next line to last to remove them from offline image. same goes for capabilities & optional features too.
Sorry guys, I try to explain me better. Take the following part of script: @echo off ... for %%p in ( Microsoft.549981C3F5F10 Microsoft.BingWeather Microsoft.DesktopAppInstaller Microsoft.GetHelp Microsoft.Getstarted Microsoft.HEIFImageExtension Microsoft.Microsoft3DViewer Microsoft.MicrosoftOfficeHub Microsoft.MicrosoftSolitaireCollection Microsoft.MicrosoftStickyNotes Microsoft.MixedReality.Portal Microsoft.MSPaint Microsoft.Office.OneNote Microsoft.People Microsoft.ScreenSketch Microsoft.SkypeApp Microsoft.StorePurchaseApp Microsoft.VCLibs.140.00 Microsoft.VP9VideoExtensions Microsoft.Wallet Microsoft.WebMediaExtensions Microsoft.WebpImageExtension Microsoft.Windows.Photos Microsoft.WindowsAlarms Microsoft.WindowsCalculator Microsoft.WindowsCamera Microsoft.windowscommunicationsapps Microsoft.WindowsFeedbackHub Microsoft.WindowsMaps Microsoft.WindowsSoundRecorder Microsoft.WindowsStore Microsoft.Xbox.TCUI Microsoft.XboxApp Microsoft.XboxGameOverlay Microsoft.XboxGamingOverlay Microsoft.XboxIdentityProvider Microsoft.XboxSpeechToTextOverlay Microsoft.YourPhone Microsoft.ZuneMusic Microsoft.ZuneVideo ) do ( Powershell -C "Write-Host 'Removing Windows App: %%p'" Powershell -C "Get-AppxProvisionedPackage -Path mount | Where {$_.DisplayName -match '%%p' } | Remove-AppxProvisionedPackage -Path mount -EA ignore" ) ... EXIT So, if I decide to exlude some of these apps from the list, keeping names but without delete the lines, is there a way to do it? For example adding REM or ::? "REM Microsoft.YourPhone" or ":: Microsoft.YourPhone" don't work. Thanks!!
Pl do as suggested by aveyo. or other way which will show you list of apps for removal from which you have to select then press ok. Code: Powershell -C "Get-AppxProvisionedPackage -Path mount | OGV -PassThru | Remove-AppxProvisionedPackage -Path mount -EA ignore" here you dont need any predefined list as list will be shown to you via powershell gui.
or if you want to remove apps using same powershell gui list on current installed w11 os then this command will go fine : Code: Powershell -C "Get-AppxProvisionedPackage -Online | OGV -PassThru | Remove-AppxProvisionedPackage -Online -EA ignore -Verbose"
Thank you @(\_/)^(\_/) Today I'll try an unattended Windows 11 installation on a VM with your commands
If you find my script working fine & want to know many more commands too then you can visit my old thread on forums : Spoiler https://forums.mydigitallife.net/threads/_-_-s-scripts.84618/ Most Welcome friend
@(\_/)^(\_/) Sorry for this topic - I already have some of your scripts - Removal - Online - 1. Remowe windows apps - powershell Spoiler: Remowe windows apps Powershell -C "Get-AppxProvisionedPackage -Online | OGV -PassThru | Remove-AppxProvisionedPackage -Online -EA ignore -Verbose" 2. cmd - Spoiler: Disable windows features Disable windows echo ====================================================== echo -------------- Disable Windows Features -------------- echo ====================================================== Powershell -EP Bypass -MTA -NOL -NONI -NOP -C "Write-Host 'Disable Windows Optional Features' -ForegroundColor Green" Powershell -EP Bypass -MTA -NOL -NONI -NOP -C "Get-WindowsOptionalFeature -Online | Where-Object {$_.State -eq 'Enabled' } | OGV -PassThru -Title 'Select Windows Optional Features to Disable' | Disable-WindowsOptionalFeature -Online -NoRestart -Verbose" echo ====================================================== - 3. cmd - Remowe windows capabilities - Spoiler: Remowe windows capabilities echo ====================================================== echo ------------- Remove Windows Capabilities ------------ echo ====================================================== Powershell -EP Bypass -MTA -NOL -NONI -NOP -C "Write-Host 'Remove Windows Capabilities' -ForegroundColor Green" Powershell -EP Bypass -MTA -NOL -NONI -NOP -C "Get-WindowsCapability -Online | Where-Object {$_.State -eq 'Installed' } | OGV -PassThru -Title 'Select Windows Capabilities to Remove' | Remove-WindowsCapability -Online -Verbose" echo ====================================================== The complete set is missing - Remove System Apps - can you share such a script? I always delete - offline - but sometimes I want to check something and delete - online.
It's counter-productive to localize powershell cmdlets parameters, like you did with get-windowscapability in the now edited post. You can always find out the integer value corresponding to a needed enum and use that instead, but you won't learn that from most So for example, just fire up powershell, and run get-windowscapability -online | where {$_.State -eq 0} 1 2 3 4 etc. until the needed results are returned (i.e. "zainstalowany" = "Installed") Code: powershell -nop -c "get-windowscapability -online | where {$_.State -eq 4} | ogv -passthru | remove-windowscapability -online -ea 0" edit: as for removing system apps on a live system, FORCE APPX UNINSTALL script is probably still the best