Category Archives: Windows

winget – like apt-get for Linux and brew for Mac?

I was today years old when I learned that winget is a thing for windows.

I powered up my ancient Lenovo ideapad FLEX 4 (so old, it cannot run Windows 11) today, and looked to see what updates where waiting. There were plenty in the Microsoft Store plus some in Windows Update. I only use this machine for running my vinyl cutter and laser engraver, so there is not much on it.

Due to the tiny SSD hard drive, I do have WinDirStat installed. It is a nice tool that will show you what is using up all your hard drive space.

I went to the WinDirStat website to look for updates:

WinDirStat – Downloads

My version was quite behind, so I was abouty to download the installer then I noticed this:

You may also install it with:

  • 📦 winget install -e –id WinDirStat.WinDirStat (or use winget upgrade subsequently)
  • 📦 scoop install extras/windirstat (requires scoop bucket add extras)
WinDirStat – Downloads

I am pretty sure I have used winget before to install some developer thing, but was unaware that it was used by other apps.

Typing “winget upgrade” showed me that it recognized several things on my PC:

C:\Users\alspl>winget upgrade
Name Id Version Available Source
-----------------------------------------------------------------------------------------------------------------------
WinMerge 2.16.18.0 x64 WinMerge.WinMerge 2.16.18.0 2.16.44.0 winget
Windows PC Health Check Microsoft.WindowsPCHealthCheck 3.6.2204.08001 3.7.2204.15001 winget
Microsoft ODBC Driver 17 for SQL Server Microsoft.msodbcsql.17 17.7.2.1 17.10.6.1 winget
Microsoft Visual Studio Code Microsoft.VisualStudioCode 1.91.1 1.96.4 winget
Visual Studio Community 2022 Microsoft.VisualStudio.2022.Community 17.4.1 17.12.3 winget
Dropbox Dropbox.Dropbox 216.4.4420 217.3.4243 winget
Google Chrome Google.Chrome.EXE 131.0.6778.267 132.0.6834.111 winget
Microsoft Visual C++ 2015-2022 Redistributa… Microsoft.VCRedist.2015+.x86 14.31.31103.0 14.42.34433.0 winget
Microsoft Visual C++ 2015-2022 Redistributa… Microsoft.VCRedist.2015+.x64 14.40.33810.0 14.42.34433.0 winget
Slack SlackTechnologies.Slack 4.39.93 4.42.115 winget
Lenovo Service Bridge Lenovo.ServiceBridge 5.0.2.9 5.0.2.17 winget
App Installer Microsoft.AppInstaller 1.23.1911.0 1.24.25200.0 winget
Dev Home Microsoft.DevHome 0.1900.687.0 0.1901.687.0 winget
13 upgrades available.

I tried “winget upgrade WinMerge.WinMerge” and saw it kick off and download the installer, then launch it. Very cool! It even has a spinning cursor while downloading :)

There is a “winget upgrade – all” option that should do all of them. The installers may pop up an authorization box you have to click on, so they are not fully automated, but still neat.

Did I do something on this computer years ago to install winget, or is it on any Windows 10/11 system just waiting to be used? Give “winget upgrade” a try on your PC and let me know if it works…

I have some upgrading to do.

Until next time…

Perforce to BitBucket Git migration – rename $File$ RCS keywords in source files

After migrating from Perforce to Git (BitBucket, in our case) at work, I learned that Git does not support any embedded source code keywords for replacement on check in. In our case, we use things like:

/*-------------------------------------------------------------------------------
 *      File Name: $File$
 *  Creation Date: $DateTime$
 *         Author: $Author$
 *       Revision: $Revision$
 *    Change List: $Change$

…and at the end of the files…

// End of $File$

On Submit, Perforce will replace those keywords with useful information, such as the username ($Author$) that did the submit, the data and time of the submit ($DateTime$) and the filename ($File$). I find this very useful when looking at source code outside of Perforce, since it tells me how new or old the code is. (Anyone who’s ever had to print out a ton of code for a group code review knows how easy it is to end up looking at the wrong version of the file… Usually not discovered until someone finds a bug you know you already fixed ;-)

Since Git does not support this, I wanted to at least search/replace “$File$” to be the actual filename of the source file. I am sure there are many ways to do this, but I ended up using a PowerShell script, based on code I found some web searches (probably on Stack Exchange or similar):

Get-ChildItem "*.h" -Recurse | ForEach-Object {
echo Processing: $_.FullName
$content = Get-Content $_.FullName
$newtext = ((Get-Content -path $_.FullName -Raw) -replace '\$File\$',$_.Name)
[system.io.file]::WriteAllText($_.FullName,$newtext)
}

In this case, this code specifically targets “.h” files at or below the directory you run the script in. I expect you can make a multi-filter that does .c and .h at one time, but I only needed to do this once so I ran it like this, then edited the “*.h” to be “*.c” and ran it again. (You’d change it to whatever your source file extensions are, like .cs or whatever.)

The [system.io.file] tip came from someone who noticed the other output would always add a blank line at the end of the file. This method re-writes the file as-is.

WARNING: I did notice that some files get messed up if they contain special characters. It would put some garbage (when viewing in a text editor) in place of things like weird apostrophes and such, so if you use this, make sure to diff your files before checking them back in and revert any goofs that “-replace” causes. I had to revert about one dozen blocks in my code.

I also had to run a command to grant my Windows 11 machine permission to even execute a PowerShell script.

Hope this helps someone else, and saves them a few hours of research…

Upgrade from Windows 11 Home to Windows 11 Pro using an old Windows key

I have a Windows laptop that came with Windows 10 Home. Unfortunately, Home is missing two features I wanted to use — Remote Desktop (so I could connect to this machine from elsewhere) and Bitlocker (so I can encrypt the hard drive). Those features require upgrading to Windows 10 Pro.

I was able to do the free upgrade to Windows 11 Home, but upgrading to Windows 11 Pro was a $99 charge in the Microsoft Store. That’s quite a bit of money for two minor features I wanted to use.

Fortunately, over on the Sub-Etha Software Facebook page, Jason D. had a solution.

“If you have an old key for Win 7 Pro, it should work. Seeing as how the system has an OEM key on it now, though, who knows… You could always just bite the bullet and upgrade, I had to do that on my Surface.”

– Jason D.

I recalled I had Windows 7 Pro in the past, which I ran on my Mac under the Parallels PC emulator. I looked through my old registration files and found my activation key for Windows 7 Pro. Using it, I was able to upgrade my Windows 11 Home version to Windows 11 Pro.

Thank you, Jason, for the great idea! I’d never run that old Windows 7 install again, so this was a great way to re-use a license I already paid for. (I also have a Windows 10 Pro license, but I have to keep that one for running it on my emulator.)

Hopefully Jason’s suggestion also helps someone else…

Until next time…