Archive for the ‘Windows Development’ Category
Posted by jpluimers on 2023/08/29
Often the power is in the combinations of tools.
Read until the epilogue…
Prologue
In this case, I needed to be able to query the JSON results of calls to REST services from the command-line so I could process them in Batch files.
Since I could not find anything readily available, I originally Originally I opted for the PowerShell command-line scripting tool, as that ships with recent Windows versions and can re-use anything that .NET brings. But though [Wayback/Archive] .NET has built in JSON serialization support, there is [Wayback/Archive] no querying support in it.
Then I thought about Delphi, as it [Wayback/Archive] too has a built-in JSON parser, but even the well known [Wayback/Archive] JSON SuperObject library has no query support.
Back to .NET, which – like Delphi – has a well known and respected third party JSON library as well: [Wayback/Archive] NewtonSoft JSON aka JSON.net and that one [Wayback/Archive] does have support for querying JSON with the SelectToken function.
That’s the fundament of the rest of this article, with the potential to be used in a cross-platform as well.
So no need for a plan B.
Read the rest of this entry »
Posted in *nix, *nix-tools, .NET, Batch-Files, Conference Topics, Conferences, Development, Event, JavaScript/ECMAScript, jq, JSON, Power User, Scripting, Software Development, Windows, Windows Development | Leave a Comment »
Posted by jpluimers on 2023/05/18
After using Chocolatey for a long time and writing about it, I have written a few articles on other Windows package managers like winget and Scoop.
Part of the reason was that I wanted to install new systems in a semi-automatic way including WSL2 (Windows Subsystem for Linux 2).
As I have spent quite some time getting treated against metastasised rectum cancer, I missed part of the evolvement of WSL into WSL2 and of the winget evolvement.
The good news is that this simplified the scripted installation of WSL2 a lot, as over time, this got very easy, as confirmed in these posts/messages I found via [Wayback/Archive] winget wsl2 – Google Search:
I even found back this was announced when I was still in hospital: during the Build 2020 conference. A summary is at [Wayback/Archive] The Windows Subsystem for Linux BUILD 2020 Summary – Windows Command Line describing the introduction of wsl.exe --install and that it defaults to install WSL 2 as back-then already most Windows Insider build users using WSL had switched from WSL 1 to WSL 2.
Back to installing
Yesterday, in Windows “equivalents” for bash backticks in cmd and PowerShell, I showed how to get the wsl.exe information:
C:\temp>PowerShell -Command "SigCheck "$((Get-Command -CommandType Application wsl).Path)""
Sigcheck v2.82 - File version and signature viewer
Copyright (C) 2004-2021 Mark Russinovich
Sysinternals - www.sysinternals.com
c:\windows\system32\wsl.exe:
Verified: Signed
Signing date: 09:24 15/10/2021
Publisher: Microsoft Windows
Company: Microsoft Corporation
Description: Microsoft Windows Subsystem for Linux Launcher
Product: Microsoft« Windows« Operating System
Prod version: 10.0.19041.1320
File version: 10.0.19041.1320 (WinBuild.160101.0800)
MachineType: 64-bit
This was on one of my Windows 10 systems with version 21H2.
The installation progress was as follows and took ome 3 minutes on a 50 Mibit/s fiber connection:
C:\temp>wsl.exe --install
Installing: Virtual Machine Platform
Virtual Machine Platform has been installed.
Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
Downloading: WSL Kernel
Installing: WSL Kernel
WSL Kernel has been installed.
Downloading: Ubuntu
The requested operation is successful. Changes will not be effective until the system is rebooted.
Time to play around (:
–jeroen
Posted in Batch-Files, Chocolatey, Development, Power User, Scoop, Scripting, Software Development, Windows, Windows Development, winget, WSL Windows Subsystem for Linux | Leave a Comment »
Posted by jpluimers on 2023/05/09
Last month, I wrote Need to take a look a Scoop (as a long time Chocolatey user).
So I did, and started with a list of my Chocolatey installs grouped by functionality in order to expand the table towards winget and [Wayback/Archive] GitHub – ScoopInstaller/Scoop: A command-line installer for Windows.
This was a good way to start learning, and by already doing this, got learned this:
- Whereas Chocolaty has a global searchable community package index at [Wayback/Archive] Chocolatey Software | Packages which is moderated too.
- Scoops works differently. There are many buckets you can get your applications from, and there is no Scoop maintained index of them.
Let’s focus on the latter for a bit:
From the above, I got a feeling that Scoop is way more like the Linux Package Managers than WinGet and Chocolatey are.
–jeroen
Read the rest of this entry »
Posted in Chocolatey, Development, Power User, Scoop, Software Development, Windows, Windows Development, winget | Leave a Comment »
Posted by jpluimers on 2022/10/25
With the rise of *nix tools and infrastructure on Windows (including, but certainly not limited to Visual Studio Code and Windows Subsystem for Linux), I need to get acquainted to the new ways these interface to the Windows Console.
Since Windows Console is from the (now obsolete) UCS-2 days, so it is not even fully Unicode aware, and has trouble with UTF-8, UTF-16.
So here are some links for my reading list:
–jeroen
Read the rest of this entry »
Posted in *nix, *nix-tools, CommandLine, ConPTY, Console (command prompt window), Development, Linux, Power User, Software Development, Windows, Windows 10, Windows 11, Windows Development, Windows Terminal, WSL Windows Subsystem for Linux | Leave a Comment »
Posted by jpluimers on 2022/10/19
Posted in Development, FortiGate/FortiClient, Hardware, Network-and-equipment, Power User, Security, Software Development, VPN, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows 9, Windows Development, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, Windows Vista, Windows XP | Leave a Comment »
Posted by jpluimers on 2022/07/21
Over the last years, Microsoft has been retiring a lot of KB articles that in some situations can be of great value, not just when using legacy systems: sometimes they are the only source of accurate information on current systems as well.
I was glad to find that many of the retired articles made it to the [Wayback/Archive.is] Microsoft KB Archive – BetaArchive Wiki.
From that page:
Read the rest of this entry »
Posted in Development, Power User, Software Development, Windows, Windows Development | Leave a Comment »
Posted by jpluimers on 2022/06/30
Even with a batch file saved as UTF-8 (with or without BOM), by default it does not show most non-ASCII Unicode characters.
The reason is that the default codepage usually is an ANSI one like codepage 437.
Thanks [Wayback] niutech for answering [Wayback/Archive.is] Unicode symbols in a batch file – Stack Overflow:
You can manually set the codepage to UTF-8 by typing chcp 65001 at the top of your batch file.
Codepage 65001 is Windows speak for the UTF-8 code page. I have some more blog entries mentioning codepage 65001.
An example where I needed this was to show how to address the localghost from a batch file (see The spookback localghost address to resolve 👻). This was the resulting UTF-8 saved batch file:
chcp 65001
ping 👻
ping xn--9q8h
For single-byte non-ASCII characters, you can usually get away with setting the encoding of your batch file to your default code page as mentioned in [Wayback/Archive.is] cmd – Using box-drawing Unicode characters in batch files – Stack Overflow.
–jeroen
Posted in Batch-Files, Development, Encoding, Scripting, Software Development, Unicode, UTF-8, Windows Development | Leave a Comment »
Posted by jpluimers on 2022/06/16
Adapted from [Archive.is] How can you export the Visual Studio Code extension list? – Stack Overflow, presuming that code is on the PATH:
- From the command-line interface on MacOS, Linux, BSD or on Windows with
git installed:
code --list-extensions | xargs -L 1 echo code --install-extension
- From the command-line interface on MacOS, Linux, BSD or on Windows without
git installed:
code --list-extensions | % { "code --install-extension $_" }
or, as I think, more clearly (see also [WayBack] syntax – What does “%” (percent) do in PowerShell? – Stack Overflow):
code --list-extensions | foreach { "code --install-extension $_" }
or even more explanatory:
code --list-extensions | ForEach-Object { "code --install-extension $_" }
- From the command-line interface on Windows as a plain
cmd.exe command:
@for /f %l in ('code --list-extensions') do @echo code --install-extension %l
- On Windows as a plain
cmd.exe batch file (in a .bat/.cmd script):
@for /f %%l in ('code --list-extensions') do @echo code --install-extension %%l
- The above two on Windows can also be done using PowerShell:
PowerShell -Command "code --list-extensions | % { """""code --install-extension $_""""" }"
Note that here too, the % can be expanded into foreach or ForEach-Object for clarity.
All of the above prepend “code --install-extension ” (note the trailing space) before each installed Visual Studio Code extension.
They all give you a list like this which you can execute on any machine having Visual Studio Code installed and its code on the PATH, and a working internet connection:
code --install-extension DavidAnson.vscode-markdownlint
code --install-extension ms-vscode.powershell
code --install-extension yzhang.markdown-all-in-onex
(This is about the minimum install for me to edit markdown documents and do useful things with PowerShell).
Of course you can pipe these to a text-file script to execute them later on.
The double-quote escaping is based on [Wayback/Archive.is] How to escape PowerShell double quotes from a .bat file – Stack Overflow:
you need to escape the " on the command line, inside a double quoted string. From my testing, the only thing that seems to work is quadruple double quotes """" inside the quoted parameter:
powershell.exe -command "echo '""""X""""'"
Via: [Archive.is] how to save your visual studio code extension list – Google Search
--jeroen
Posted in *nix, *nix-tools, .NET, bash, Batch-Files, CommandLine, Console (command prompt window), Development, Mac OS X / OS X / MacOS, Power User, PowerShell, PowerShell, Software Development, Visual Studio and tools, vscode Visual Studio Code, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Development, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, WSL Windows Subsystem for Linux, xargs | Leave a Comment »
Posted by jpluimers on 2022/05/18
Subtitle:
GetFullPathName thread-unsafety because of SetCurrentDirectory isn’t, so derived functions (like Delphi GetDir/ChDir/TPath.GetFullPath, or .NET System.IO.Path.GetFullPath) are not thread-safe either (via The Old New Thing)
A while ago I got a big reminder because of [Wayback] What are these dire multithreading consequences that the GetFullPathName documentation is trying to warn me about? | The Old New Thing:
Read the rest of this entry »
Posted in Delphi, Development, Pascal, Software Development, Turbo Pascal, Windows Development | Leave a Comment »