Windows

Introduction

I dislike Windows, gotta get that out of the way now.  I still have to use it sometimes.  I only ever regularly use it for gaming.  Wine, Steam and Proton are great for Linux; I use it for a lot of games.  But many game developers are not friendly; to Wine or Linux in general.  I wish that more games ran natively on Linux.  

Anyways, since I keep a few Windows machines around, here are items that I want to keep around and share.

Recovery Drive

One might not realize this is important.  One might even make excuses about recovery partitions, etc.  But if you've had a hard drive die on you, or if you load lots of different OSes, you will realize that making a recovery USB drive is a necessity.  

This USB drive is per system.  Another important nuance.  The Windows ecosystem still has many systems not sending their drivers to Microsoft.  It is a sad state considering where technology is, but I won't rant beyond that statement.  I hope.

Well, that didn't last long.  It is hard to understand why there are tons of recovery options in Windows 10's settings app, but not the option to create a recovery USB.  Most of the searches I've made are look for "Create a recovery drive" in the Start Menu and follow the instructions.  That is exactly what Microsoft says too.  :-(  Anyways, DO IT RIGHT NOW!

Fixing Boot Issues

[blah blah blah, Windows sucks, blah blah blah]

Windows 11 Won't Shutdown

Another rant about Windows is expected and deserved one this one.  How stupid is it that if you change the power button to Sleep your system, selecting Shutdown in the Start Menu makes it go to sleep instead of shutting down?!?!?  

Anyways, Start Menu -> search for & launch Control Panel -> Power Options -> Change what power buttons do.  

BTW, in case you're curious, all the options were set to Sleep; and I did not set that!  🙄

Disc Cleanup

On Windows 10 I wanted an easy way to clean up (out?) files and then to optimize for quick file access.  This is supposedly not needed these days for 2 reasons.  First, SSDs do not have rotating discs, so do not need to move the right sector to the reader-arm.  Second, newer versions of NTFS are not supposed to write files contiguously.  Though files that change in size will get fragmented.

An "interesting" tangent, to quote Microsoft's defrag.exe:

File fragments larger than 64MB are not included in the fragmentation statistics.

Go figure.

To do this quickly, mindlessly, and routinely, I needed a batch file or PowerShell script.  The quickest thing was to create a batch file.  First, just once, run cleanmgr.exe /sageset:1 and select all the categories of files you want to remove.  Read Microsoft's cleanmgr documentation thoroughly before setting any values.

Second, put these two lines in a batch file.  Notice that it is "sagerun" instead of "sageset".

cleanmgr.exe /sagerun:1

defrag.exe /c /u /x

The batch file and initial command should be done from an elevated command prompt.  The easiest way to get there is to click on Windows Button, search for "command prompt", right-click and choose "Run as Administrator".  To get more information, click here.

The first time you run this it may take a long time.  If you run it regularly, it should take less time.  Unless you've done a lot of file changes; which includes updates, DLCs, and getting all those vacation pictures off your camera.  I'd also be careful about cleaning up "Windows Update" stuff.  Doing so after an update might be a needless worry.  But Microsoft is known for strange things and you might not be able to uninstall updates.  

Optional Updates

The sad state of the Windows eco-system is that one doesn't know if they should trust drivers from Microsoft or those from the manufacturer of the device (meaning network card, video card, peripheral, etc).  Also, you get a lot of "fly-by-night" manufacturers out there that throw together their devices & software drivers.  Then abandon them.  

Tangentially,  yes, I get startups.  I would not buy from them expecting a long-lasting, well-supported Windows device.  If it was Linux, unless it is a very odd device, once submitted, support is usually very good and stays around for a long time.

Anyways, and there are exceptions, but I try to always use the drivers coming from Microsoft.  In System Settings -> Windows Update, there is a button for "Optional Updates".  Try each one by itself, and reboot in between each installation.  This makes it easier to roll back bad drivers.  I know it sounds like a pain, but it is safer.  If something doesn't work, uninstall it, and don't forget to keep the manufacturer's drivers around.  On a drive that isn't in your computer.

Recovery Resizing

I can't believe that Microsoft has an update that requires a user to go through the effort to repartition their own recovery partition.  Anyways, if you get error 0x80070643 when updating your Windows, use these instructions to resize your recovery partition.   For posterity, they are copied/shortened below.  Use at your own risk; understand before you act.  :-)

This should work on most partition schemes.  If you did something custom, you should be able to adjust the instructions.

Update Failures

https://techcommunity.microsoft.com/t5/windows-insider-program/windows-11-23h2-install-issue-with-insider-preview-0x80248014/m-p/3973170

Copying Active Directory

After looking around for how to copy users and groups from one Active Directory domain to a test one, none had the complete picture.  Well, a few were almost complete and a few had too many manual processes.  My version can be found here [still needs to be moved to public github repo].

The basic steps are below.  More info is in the MD file in the repo.

BTW, I saw a lot of folks doing users and then groups.  I'm trying to think ahead and decided to do groups and then users in case I figure out how to export group membership and import that too.