PowerShell Command for Add-AppxPackage -register

fxart

New Member
Messages
13
Reaction score
0
Hi Guys, please. a big flavour. Anyone can help me to execute this powershell command during the OS setup?
Get-AppxPackage -allusers | foreach {Add-AppxPackage -register “$($_.InstallLocation)\appxmanifest.xml” -DisableDevelopmentMode}

one time only.
I have to put into the $OEM$ folder.
Please, I can't try anything else this time. It's urgent. These OS images need my for my job.
How?
I don't know why but now, any OS after sysprep have all apps installed but no one can't be launched.
Also notepad appear installed but can't open any file.

10 Professional and Windows 11P
The user have the admin privilege.
I don't know why!
I have spent two weeks rebuilding from scratch these OS images at least 10 times without success.
Please, help me asap.
I'am a registered user.

Thanks in advance
 
When Appx packages don't work after sysprep, it's usually because you didn't follow the strict rule to disable networking during the audit phase. WU has updated packages in the background for the logged on profile.

For now, you can just add a Post-Setup (After logon) command, after loading your image:

CommandParameters
powershell-C "Get-AppxPackage -allusers | foreach {Add-AppxPackage -register \“$($_.InstallLocation)\appxmanifest.xml\” -DisableDevelopmentMode}"

To avoid this problem:

1. Only use NTLite to add or remove Appx packages from an offline image. You can do it in sysprep, but it's more work to clean up Appx provisioning so it works like a clean install.

2. Don't allow WU to run in the background and silently update Appx packages. This is why the normal rule is to disable networking while in sysprep. If you need to copy offline files, keep them on a prepared USB drive.

3. Watch out for 3rd-party installers which install UWP Apps (like NVIDIA, AMD or Intel's Control Panel). These you can download separately or extract the internal Appx packages and add them in NTLite.
 
Sorry, does not work.
Also $OEM$ folder does not contain any post setup reminder
And I have sysprepped with LAN DISABLED.

@ECHO OFF
BCDEDIT /SET {DEFAULT} BOOTMENUPOLICY LEGACY
CALL "%WINDIR%\Setup\Files\Cleanup.cmd"
rd /q /s "%WINDIR%\Setup\Files"
del /q /f "%0"

cleanup is only one script that remove all unused drivers.

And sorry If I'am very lame about this.
 
You can't run Add-AppxPackage from SetupComplete.cmd, because the script runs as SYSTEM and not as your logon user.
It must be run in their user profile, after logon. NTLite does this by creating a RunOnceEx task.

1. If you wanted to do this in SetupComplete, it requires a "reg add" command to add the PS command. That's why it's easier to load the image, and have NTLite apply the Post-Setup command.

2. The alternative is mount Default User's NTUSER.DAT, and manually add the RunOnce task yourself.
Code:
reg load HKLM\TEMP NTUSER.DAT
regedit

- Add "HKLM\TEMP\Software\Microsoft\Windows\CurrentVersion\RunOnce" REG_SZ name -> "New Task"
- Add REG_SZ value -> powershell -C "Get-AppxPackage -allusers | foreach {Add-AppxPackage -register \“$($_.InstallLocation)\appxmanifest.xml\” -DisableDevelopmentMode"

Code:
exit
reg unload HKLM\TEMP
 
Back
Top