Optimize-Offline - SetupComplete.cmd - Post-Install (old method)

If you want to integrate your own scripts or programs with Optimize-Offline's SetupComplete.cmd, follow this:

1. Edit the Optimize-Offline.ps1 file using Notepad++

  • search for the line: If (Test-Path -Path "$AdditionalPath\Setup\* inside the .ps1 file:
  • replace this whole function:
1
2
3
4
5
If (Test-Path -Path "$AdditionalPath\Setup\*")
{
    New-Container -Path "$MountFolder\Windows\Setup\Scripts"
    Get-ChildItem -Path "$AdditionalPath\Setup" -Exclude README.md -ErrorAction SilentlyContinue | Copy-Item -Destination "$MountFolder\Windows\Setup\Scripts" -Recurse -ErrorAction SilentlyContinue
}

with this new one:

1
2
3
4
5
6
7
If (Test-Path -Path "$AdditionalPath\Setup\Scripts\*")
{
    New-Container -Path "$MountFolder\Windows\Setup\Scripts"
    New-Container -Path "$MountFolder\Windows\Setup\Files"
    Get-ChildItem -Path "$AdditionalPath\Setup\Scripts" -Exclude README.md -ErrorAction SilentlyContinue | Copy-Item -Destination "$MountFolder\Windows\Setup\Scripts" -Recurse -ErrorAction SilentlyContinue
    Get-ChildItem -Path "$AdditionalPath\Setup\Files" -ErrorAction SilentlyContinue | Copy-Item -Destination "$MountFolder\Windows\Setup\Files" -Recurse -ErrorAction SilentlyContinue
}

animated_gif_tutorial
(Open .gif animation in a new browser tab to enlarge)

  • save the changes in the Optimize-Offline.ps1 file.

2. Place your scripts and files in the Optimize-Offline's "Additional" directory:

  • go to your Optimize-Offline's \Resources\Additional\ directory and remove the default Setup folder from there, replace it with my own Setup folder with proper structure designed for the updated function above.
  • edit the SetupComplete.cmd script from within it using Notepad++ - as you can see i've added some commands there as an example for you, the REM is a commented line, if you want to call another .cmd file you have to use the call command, i've added the line about KMS_VL_ALL as an example.
  • remember to always place all your scripts and files in the \Resources\Additional\Setup\Files and point to them in the SetupComplete.cmd script at \Resources\Additional\Setup\Scripts.

The above is just a simplified example of what SetupComplete.cmd scripting is capable of.

More details about SetupComplete.cmd and Post-Install/Unattended scripting in general can be found in this Microsoft's article.
Also, Google is your friend.

Good luck!

This is an old way for the old Optimize-Offline method from here

Edit
Pub: 15 Jul 2019 10:39 UTC
Edit: 15 Jul 2019 17:37 UTC
Views: 803