tiny11builder icon indicating copy to clipboard operation
tiny11builder copied to clipboard

How about powershell

Open quangkieu opened this issue 2 years ago • 8 comments

I think if moving to powershell, you could do a search for prefix app name and remove them so that would work with any win version And if we use array of prefix, it could do a loop through and remove them

quangkieu avatar Feb 27 '23 13:02 quangkieu

Agree.

Not a quick answer, but long-term PowerShell will have more flexibility.

jasonpatrickellykrause avatar Feb 27 '23 13:02 jasonpatrickellykrause

can do that with batch scripting too pretty easily. for loop against an app index file.

rhinotastic avatar Feb 27 '23 21:02 rhinotastic

I understand the commodity of using bat files, as I am also used to them and because they are simpler, they are easy to read.

Still, in bat files we could use some basic functions to at least make the bat file more readable. I'm working on it in my fork, I will share it soon.

panreyes avatar Feb 28 '23 08:02 panreyes

That would be ideal :)

In any case, here's another solution that does not require Powershell scripting: https://github.com/ntdevlabs/tiny11builder/pull/14/files#diff-251038c5e6cc6da639f0f2025d3ecdf6517fc0d8ac4901754bc1883ba2e0a796R208

powershell "Get-AppxProvisionedPackage -Path %TINY11SCRATCHDIR% | Select PackageName" > %TINY11DIR%\tmp\provisioned_packages_in_image.txt

for /f %%p in ('type remove_provisioned_packages.txt') do (
	for /f %%i in ('findstr %%p %TINY11DIR%\tmp\provisioned_packages_in_image.txt') do (
		call :remove_provisioned_package %%p %%i
	)
)
del /f %TINY11DIR%\tmp\provisioned_packages_in_image.txt

panreyes avatar Feb 28 '23 23:02 panreyes

It sounds like you just like using powershell so want everything to be in powershell.(no offence meant fyi, it's just common for people to want to do things in their preferred or fav language/script). Batch has been used for this kind of thing for more than 30 years. It's still used for this heavily at enterprise level. We do a lot of very custom builds and it's all pretty much standard methods using microsoft tools with some 3rd party or inhouse tools. That whole powershell script above to replace 1 line in batch that uses a standard microsoft tool for this exact job... Part of the problem with rolling your own methods is when the next person comes along and is expecting the standard approach and finds all this custom methods instead of use of standard tools and there's some bugs to figure out it's a mess, particularly when the project grows.

Can still use powershell but i would really steer clear of breaking from non standard methods of doing things. There's tools that exists and are supported and provided for free by microsoft for this very purpose, use them.

rhinotastic avatar Mar 01 '23 16:03 rhinotastic

Both solutions are ok. To be honest, powershell would be better, but C# would be the best.

I will give a point to the powershell solution to not requiring oscdimg.exe, as distributing that exe file might be problematic license-wise.

panreyes avatar Mar 01 '23 17:03 panreyes

Hi everyone, For information I have an open pull request #15 that translate that bat script to a PowerShell script. I also developed a small tool to get the latest windows 11 iso from Microsoft, which you can find linked in the readme.md that is edited in the pull request. I tried to improve some things to make it more readable, more easy to maintain, and move a small part of the configuration to an external json file.

ianis58 avatar Mar 01 '23 23:03 ianis58

I wrote a similar tool years ago that uses ps under the hood (https://github.com/buildcenter/WindowsBuilder). I've since been mostly on Linux and the project probably needs more love. I reckon it still works on win11 with minor changes.

imacks avatar Mar 27 '23 02:03 imacks