Search code examples
windowspowershellregistry

Remove Components from Windows 10 like ntlite does


I only started to program c++ half a year ago, and would be so happy if you could just help me out by giving me a point to start with.

I want to understand how ntlite removes drivers from the iso. I want to know what do I need to learn/know/read about to program a tool myself that removes stuff like that. For example the w-lan drivers or Cortana.

By researching I came across:

  • the windows registry
  • powershell

...and that's it. Nothing like "learn the powershell to tweak your system tutorial" and before I start reading a book about these topics, I wanted to know if it is the right way to achieve my goal?

I am sorry if my question is unwelcome or stupid. I just want to learn about these things and can't find the right way to start.

Thanks in advance!


Solution

  • If you want to remove elements from Windows, you can do that using the Add-WindowsOptionalFeature and Remove-WindowsOptionalFeature PowerShell Cmdlets.

    Let's say you wanted to remove the new Calc.exe and return to the old, correct Calc.exe app.

    You can do that in your running Windows Instance using this command (when running PowerShell as an Administrator)

    Disable-WindowsOptionalFeature -Online  -FeatureName "Calc" -PackageName
    "Microsoft.Windows.Calc.Demo~6595b6144ccf1df~x86~en~1.0.0.0"
    

    If you wanted to remove it from a Windows Image instead, first you have to mount the Windows image by mounting install.wim from the disc using the Mount-WindowsImage cmdlet, like this.

    Mount-WindowsImage -ImagePath "c:\imagestore\install.vhd" -Index 1 -Path "c:\offline"
    

    This would mount the image to your c:\Offline folder. The folder needs to exist first, BTW.

    Next, to disable the feature in the Windows Image.

    Disable-WindowsOptionalFeature -Path "c:\offline" -FeatureName "Calc" -PackageName
    "Microsoft.Windows.Calc.Demo~6595b6144ccf1df~x86~en~1.0.0.0" -Remove
    

    When that's done, you save the changes using:

    Dismount-WindowsImage -Path "c:\offline" -Save
    

    NtLite and these PowerShell tools all use the Deployment Image Servicing Manager tool, DISM, and its C# libraries to actually enact the changes. If you want to know more, read this and this.