memstechtips / UnattendedWinstall

Personalized Unattended Answer Files that helps automatically debloat and customize Windows 10 & 11 during the installation process.
MIT License
2.77k stars 338 forks source link

[FR] can there be added an option to install dot net framework 3.5 automatically? #19

Closed ghost closed 2 months ago

ghost commented 3 months ago

PS: I flash windows on a lot of PCs and most of them need this framework for various purposes, and it really is hectic to install it in each PCs since I batch install

Syntax3rror404 commented 3 months ago

Not tested but something like that i think:

<settings pass="windowsPE">
    <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <ImageInstall>
            <OSImage>
                <InstallToAvailablePartition>false</InstallToAvailablePartition>
            </OSImage>
        </ImageInstall>
    </component>
</settings>
<settings pass="offlineServicing">
    <component name="Microsoft-Windows-NetFx3" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Enable>true</Enable>
    </component>
</settings>
memstechtips commented 3 months ago

@Subhashis2007 can you test out @Syntax3rror404 script and see if it works for you?

ghost commented 3 months ago

For sure, I'll try today.

ghost commented 3 months ago

@memstechtips @Syntax3rror404 I added it before audit user part and it simply resulted the iso into this,

2024-06-30_06-13_1

my unattended.xml https://hastebin.skyra.pw/kewuvofiyu.htm

Syntax3rror404 commented 3 months ago

Hmmmm if this not works, we can try it with dism like that:

Offline, but needs the cab containing the req files.

DISM /Image:C:\test\offline /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:D:\sources\sxs

OR

Online, needs internet connection.

DISM /Online /Enable-Feature /FeatureName:NetFx3 /All

Source: https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/deploy-net-framework-35-by-using-deployment-image-servicing-and-management--dism?view=windows-11

@memstechtips do you know, if the microsoft images containing the .net framework 3.5? If yes we sould be able to add the offline dism command to the powershell scripts????

ghost commented 3 months ago

@memstechtips do you know, if the microsoft images containing the .net framework 3.5? If yes we sould be able to add the offline dism command to the powershell scripts????

It does, I know for sure. Since this exists

2024-06-30_07-22 see

Syntax3rror404 commented 3 months ago

In your link the source of .net framework is the network:

To install .NET Framework 3.5 from installation media located on a network share, use the following command:

PowerShell

Install-WindowsFeature Net-Framework-Core -source \network\share\sxs Where \network\share\sxs is the location of the source files.

For more information about the Install-WindowsFeature cmdlet

Source: https://learn.microsoft.com/vi-vn/windows-hardware/manufacture/desktop/enable-net-framework-35-by-using-windows-powershell?view=windows-11

But you can try the following command on a clean system

DISM /Image:C:\test\offline /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:D:\sources\sxs

Please set Source path to your right path. If this works, we you can simply add this to the xml and you're done :)

ghost commented 3 months ago

Source: https://learn.microsoft.com/vi-vn/windows-hardware/manufacture/desktop/enable-net-framework-35-by-using-windows-powershell?view=windows-11

check this

and sorry lol, I sent that in a hurry

Syntax3rror404 commented 3 months ago

Ok, then we can try this. Not tested hope this works. I can test it tomorrow.

<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="windowsPE">
        <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Order>1</Order>
                    <Description>Install .NET Framework 3.5</Description>
                    <Path>DISM /Image:C:\test\offline /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:D:\sources\sxs</Path>
                </RunSynchronousCommand>
            </RunSynchronous>
        </component>
    </settings>
</unattend>

If this is not enough, we need a more complex batch script

Syntax3rror404 commented 3 months ago

Or something like this to get near to your example in your link:

<!-- Command File Template for DISM Execution -->
<File path="C:\Windows\Setup\Scripts\install_netfx35.cmd"><![CDATA[
@echo off
Title .NET Framework 3.5 Offline Installer
for %%I in (D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist "%%I:\\sources\boot.wim" set setupdrv=%%I
if defined setupdrv (
echo Found drive %setupdrv%
echo Installing .NET Framework 3.5...
Dism /online /enable-feature /featurename:NetFX3 /All /Source:%setupdrv%:\sources\sxs /LimitAccess
echo.
echo .NET Framework 3.5 should be installed
echo.
) else (
echo No installation media found!
echo Insert DVD or USB flash drive and run this file once again. 
echo.
)
pause
]]>
</File>

<!-- Start the script to install NET Framework 3.5 -->
<Extensions>
    <File path="C:\Users\Default\AppData\Local\Microsoft\Windows\Shell\LayoutModification.xml"><![CDATA[
    <LayoutModificationTemplate Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
        <LayoutOptions StartTileGroupCellWidth="6" />
        <DefaultLayoutOverride>
            <StartLayoutCollection>
                <StartLayout GroupCellWidth="6" xmlns="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" />
            </StartLayoutCollection>
        </DefaultLayoutOverride>
    </LayoutModificationTemplate>
    ]]></File>
</Extensions>
</unattend>
memstechtips commented 3 months ago

I haven't tested your script yet but I think we have 2 choices:

  1. Either write a script that automatically downloads and installs .NET FX 3.5 during the OOBE phase (This will require an internet connection)
  2. Download the .NET FX 3.5 package and add it to your ISO with AnyBurn. Then include a command in the answer file that runs that package during one of the Windows installation phases.

Thoughts?

Syntax3rror404 commented 3 months ago

It looks to me, that .Net 3.5 is offline available.

See link from @Subhashis2007 https://winaero.com/how-to-offline-install-net-framework-3-5-in-windows-11-with-dism/

The batch script is also from this side. I think to call this script in the setup should work?!

ghost commented 3 months ago

I haven't tested your script yet but I think we have 2 choices:

  1. Either write a script that automatically downloads and installs .NET FX 3.5 during the OOBE phase (This will require an internet connection)
  2. Download the .NET FX 3.5 package and add it to your ISO with AnyBurn. Then include a command in the answer file that runs that package during one of the Windows installation phases.

Thoughts?

it is better offline, since the package already exists inside the iso

ghost commented 3 months ago

The batch script is also from this side. I think to call this script in the setup should work?! the script looks good tho. and it is dynamically detects installation drive. I'll try and tell.

memstechtips commented 2 months ago

.NET 3.5 auto enabled in https://github.com/memstechtips/UnattendedWinstall/commit/a9348a19ad425bb840c2a3e4e67501a81715ef66

ghost commented 2 months ago

.NET 3.5 auto enabled in a9348a1

thanks a lot,