The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,513 other followers

Archive for September 29th, 2021

Windows Sandbox: a feature I forgot about

Posted by jpluimers on 2021/09/29

The Windows Sandbox can be useful, but since it was never there in the first decades of my Windows usage, I forgot it was added.

I wonder how it is implemented, as it is really useful to test out new stuff, but I wonder what it protects against.

A few years back, I bumped into this because the [WayBack] Desktop Goose by samperson got viral (it can be downloaded from [WayBack/Archive.is] Desktop Goose v0.2.zip)

via [Archive.is] Samperson on Twitter: “I made a goose that destroys your computer Download it free here: samperson.itch.io/desktop-goose” / Twitter

So here are some links (you need at least build 1903 ([WayBack] Windows 10 May 2019 or 19H1) or Insider Preview Build 18305):

You can install it even if your Windows machine itself is a VM. For a physical machine, hardware virtualisation needs to be enabled (usually in the BIOS); for a VM, nested virtualisation enabled (check that in your virtualisation environment: Hyper-V, ESXi and others vary slightly on how to enable this).

Installation inside the Windows machine can be done via PowerShell (or the UI):

Note that starting the SandBox from an x86 process might require you to run a different WindowsSandBox.exe; see [WayBack] Launching Wsb (Windows Sandbox Config file) gives error – Total Commander:

you can use C:\WINDOWS\Sysnative\WindowsSandbox.exe in stead of C:\WINDOWS\System32\WindowsSandbox.exe in TC 32bit.

Also see:
[WayBack] On 64-bit Windows versions, some files and folders shown by Windows Explorer are not shown by Total Commander!

[WayBack] Windows x64: Explorer vs TC: Content of System32 different

–jeroen

Read the rest of this entry »

Posted in Development, Power User, Software Development, Windows, Windows Development | Leave a Comment »

Moore’s law has almost ended: back to the future

Posted by jpluimers on 2021/09/29

[WayBack] We’re approaching the limits of computer power – we need new programmers now | John Naughton | Opinion | The Guardian

Ever-faster processors led to bloated software, but physical limits may force a return to the concise code of the past

So back to optimisation and maybe even assembly language.

Which brings back the days gone by.

–jeroen

Read the rest of this entry »

Posted in Algorithms, Assembly Language, Development, Software Development | Leave a Comment »

PowerShell error in a script but not on the console: The string is missing the terminator: “.

Posted by jpluimers on 2021/09/29

The below one will fail in a script, both both work from the PowerShell prompt:

Success

Get-NetFirewallRule -DisplayGroup "File and Printer Sharing" | ForEach-Object { Write-Host $_.DisplayName ; Get-NetFirewallAddressFilter -AssociatedNetFirewallRule $_ }

Failure

Get-NetFirewallRule –DisplayGroup "File and Printer Sharing" | ForEach-Object { Write-Host $_.DisplayName ; Get-NetFirewallAddressFilter -AssociatedNetFirewallRule $_ }

The error you get this this:

At C:\bin\Show-File-and-Printer-Sharing-firewall-rules.ps1:5 char:52
+ ... -TCP-NoScope" | ForEach-Object { Write-Host $_.DisplayName ; Get-NetF ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: ".
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

Via [WayBack] script file ‘The string is missing the terminator: “.’ – Google Search, I quickly found these that stood out:

Cause and solution

Before DisplayGroup, the first line has a minus sign and the second an en-dash. You can see this via [WayBack] What Unicode character is this ?.

Apparently, when using Unicode on the console, it does not matter if you have a minus sign (-), en-dash (–), em-dash (—) or horizontal bar (―) as dash character. You can see this in [WayBack] tokenizer.cs at function [WayBack] NextToken and [WayBack] CharTraits.cs at function [WayBack] IsChar).

When saving to a non-Unicode file, it does matter, even though it does not display as garbage in the error message.

Similarly, PowerShell has support for these special characters:

    internal static class SpecialChars
    {
        // Uncommon whitespace
        internal const char NoBreakSpace = (char)0x00a0;
        internal const char NextLine = (char)0x0085;

        // Special dashes
        internal const char EnDash = (char)0x2013;
        internal const char EmDash = (char)0x2014;
        internal const char HorizontalBar = (char)0x2015;

        // Special quotes
        internal const char QuoteSingleLeft = (char)0x2018; // left single quotation mark
        internal const char QuoteSingleRight = (char)0x2019; // right single quotation mark
        internal const char QuoteSingleBase = (char)0x201a; // single low-9 quotation mark
        internal const char QuoteReversed = (char)0x201b; // single high-reversed-9 quotation mark
        internal const char QuoteDoubleLeft = (char)0x201c; // left double quotation mark
        internal const char QuoteDoubleRight = (char)0x201d; // right double quotation mark
        internal const char QuoteLowDoubleLeft = (char)0x201E; // low double left quote used in german.
    }

The easiest solution is to use minus signs everywhere.

Another solution is to save files as Unicode UTF-8 encoding (preferred) or UTF-16 encoding (which I dislike).

–jeroen

Posted in .NET, CommandLine, Development, Encoding, PowerShell, PowerShell, Scripting, Software Development, Unicode, UTF-16, UTF-8, UTF16, UTF8 | Leave a Comment »

 
%d bloggers like this: