SetupComplete.cmd not executing

Same answer as above, NTLite implicitly runs every added *.ps1 with "-NoProfile -ExecutionPolicy Bypass", so changing your Execution Policy isn't required unless you wanted a different default PS setting.

1. Your commands are incorrect, they're not invoked from PS.

CommandParameters
powershellSet-ExecutionPolicy RemoteSigned -force
powershellSet-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force

2. winget scripts will fail because winget isn't ready when it's called. Either execute a winget installer script from Post-Setup (User) or "After logon" which forces winget to be updated immediately, or follow the instructions on this thread:

What changed? Post-Setup After Logon Script not run
I will try now, I really believe it will works now.
 
Just to add to this:

- 7zip.7zip.exe needs changed to 7zip.7zip

- winget install --id $app --accept-package-agreements --silent needs changed to winget install --id $app --accept-source-agreements --accept-package-agreements --silent
I am compiling again the iso, lol, I fixed the 7zip. Ty. I wonder if this is correctly.

Unfortunately, the script still not running automatically when I login the first time. I tried to run the script inside the iso file and before the script start to run, I get this.

_____
Bypass
Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by
a policy defined at a more specific scope. Due to the override, your shell will retain its current effective
execution policy of Bypass. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more
information please see "Get-Help Set-ExecutionPolicy".
At D:\sources\$OEM$\$$\Setup\FilesU\Apps.ps1:6 char:1
+ Set-ExecutionPolicy RemoteSigned
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: :)) [Set-ExecutionPolicy], SecurityException
+ FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by
a policy defined at a more specific scope. Due to the override, your shell will retain its current effective
execution policy of Bypass. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more
information please see "Get-Help Set-ExecutionPolicy".
At D:\sources\$OEM$\$$\Setup\FilesU\Apps.ps1:7 char:1
+ Set-ExecutionPolicy RemoteSigned -force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: :)) [Set-ExecutionPolicy], SecurityException
+ FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
Installing nilesoft.shell
The `msstore` source requires that you view the following agreements before using.
Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction
The source requires the current machine's 2-letter geographic region to be sent to the backend service to function properly (ex. "US").

Do you agree to all the source agreements terms?
[Y] Yes [N] No: y
---------
My script starts here.
 

Attachments

  • Screenshot 2024-04-07 201814.jpg
    Screenshot 2024-04-07 201814.jpg
    37.9 KB
Last edited:
I am compiling again the iso, lol, I fixed the 7zip. Ty. I wonder if this is correctly.

Unfortunately, the script still not running automatically when I login the first time. I tried to run the script inside the iso file and before the script start to run, I get this.

_____
Bypass
Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by
a policy defined at a more specific scope. Due to the override, your shell will retain its current effective
execution policy of Bypass. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more
information please see "Get-Help Set-ExecutionPolicy".
At D:\sources\$OEM$\$$\Setup\FilesU\Apps.ps1:6 char:1
+ Set-ExecutionPolicy RemoteSigned
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: :)) [Set-ExecutionPolicy], SecurityException
+ FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by
a policy defined at a more specific scope. Due to the override, your shell will retain its current effective
execution policy of Bypass. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more
information please see "Get-Help Set-ExecutionPolicy".
At D:\sources\$OEM$\$$\Setup\FilesU\Apps.ps1:7 char:1
+ Set-ExecutionPolicy RemoteSigned -force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: :)) [Set-ExecutionPolicy], SecurityException
+ FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
Installing nilesoft.shell
The `msstore` source requires that you view the following agreements before using.
Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction
The source requires the current machine's 2-letter geographic region to be sent to the backend service to function properly (ex. "US").

Do you agree to all the source agreements terms?
[Y] Yes [N] No: y
---------
My script starts here.
The script still needs the “--accept-source-agreements” to run without user interaction hence you getting the prompt for yes or no.

I believe that winget may not be registered yet when the script is trying to run. If you check out garlin above comment - there is a thread and guide on how to install this before the first logon and the script running via a scheduled task which has a lot of positive feedback.

You could also try adding a command to install winget at the start of your script - unsure if this would work but may be worth a try?

Hope you get it sorted
 
Back
Top