For my link archive: [Wayback/Archive] Kugane/winget: A Winget script to automatically install predefined programs and MS Store apps. Includes automatic update and cleanup job
–jeroen
Posted by jpluimers on 2024/09/03
For my link archive: [Wayback/Archive] Kugane/winget: A Winget script to automatically install predefined programs and MS Store apps. Includes automatic update and cleanup job
–jeroen
Posted in CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2024/05/23
More than a decade ago I wrote about Programmatic alternatives to Windows-L keyboard shortcut (SwitchUser / LockWorkstation).
Still, I see many scripts invoke rundll32.exe or to call the [Wayback/Archive] LockWorkStation function (winuser.h) inside user32.dll. Don’t!
The BOOL LockWorkStation()function has a calling convention that is incompatible with rundll32.exe () which will corrupt the call stack likely will lead to random problems as after two decades, this post from Raymond Chen still holds: [Wayback/Archive] What can go wrong when you mismatch the calling convention? – The Old New Thing
Posted in .NET, Batch-Files, C#, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Security, Software Development, Windows, Windows 10, Windows 11, Windows 7, Windows 8, Windows 8.1, Windows Server 2016 | Leave a Comment »
Posted by jpluimers on 2024/03/21
Via [Archive.is] Kevin on Twitter: “Gotta say this looks amazing and I actually didn’t know you can customize the command line on Windows this far. Read this blogpost by @shanselman , highly recommended. 👇 “
For my link archive: [Wayback] My Ultimate PowerShell prompt with Oh My Posh and the Windows Terminal – Scott Hanselman’s Blog
Posted in CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows, Windows 10, Windows Development | Leave a Comment »
Posted by jpluimers on 2023/10/10
For tomorrow’s post Ookla speedtest CLI for Windows has some undocumented arguments to accept license and GDPR I neede the full path to the speedtest.exe which I had installed using Chocolatey.
I know chocolatey uses a shim that redirects to the actual executable, so a simple where speedtest.exe would not cut it.
My guess would be that the generated shim allowed to either get the target pathname out, or have the target pathname encoded in it.
Luckily the first applies: a few of the shim command-line parameters are in [Wayback/Archive] Chocolatey Software Docs | Executable shimming (like symlinks but better):
You pass these arguments to an executable that is a shim (e.g. executables in the bin directory of your Chocolatey install, not choco.exe):
--shimgen-help– shows this help menu and exits without running the target--shimgen-log– logging is shown on command line--shimgen-waitforexit– explicitly tell the shim to wait for target to exit – useful when something is calling a gui and wanting to block – command line programs explicitly have waitforexit already set.--shimgen-exit– explicitly tell the shim to exit immediately.--shimgen-gui– explicitly behave as if the target is a GUI application. This is helpful in situations where the package did not have a proper .gui file.--shimgen-usetargetworkingdirectory– set the working directory to the target path. Useful when programs need to be running from where they are located (usually indicates programs that have issues being run globally).--shimgen-noop– Do not actually call the target. Useful to see what would happen if you ran the command.
But the below dumps show more more (using [Wayback/Archive] Strings – Windows Sysinternals | Microsoft Docs, [Wayback/Archive] clip | Microsoft Docs and post-processing in [Wayback/Archive] Notepad++).
Back to the second solution,
strings C:\ProgramData\chocolatey\bin\speedtest.exe | findstr speedtest.exe
showed
speedtest.exe ..\\lib\speedtest\tools\speedtest.exe Cannot find file at '..\\lib\speedtest\tools\speedtest.exe' ( speedtest.exe speedtest.exe
And towards the first,
strings C:\ProgramData\chocolatey\bin\speedtest.exe | clip
resulted in this fragment:
Posted in Batch-Files, Chocolatey, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Leave a Comment »
Posted by jpluimers on 2023/09/11
Only having really learned to speak English starting in my late teens, I never got the “smarter than the average bear” reference, so I filed what I thought was a bug early 2019: [Wayback/Archive] “You must be smarter than the average bear…” after upgrading to 7zip.install v18.6 and notepadplusplus.install v7.6.2 · Issue #1700 · chocolatey/choco which last year got this useful comment
I had this for several packages now, since I am updating them daily.
I am assuming there is a way to remove versions, which leads to this error until there is a new update.
It was confirmed this summer from
I’m smarter than the average bear at least once or twice a month. I think it might be packages which are pulled back and you happen to have installed that version
The bug got referenced this summer from [Wayback/Archive] Remove warning message about “smarter than the average bear” · Issue #3186 · chocolatey/choco.
This in turn lead to [Wayback/Archive] (#3186) Remove easter egg “You are smarter than the average bear …” by pauby · Pull Request #3276 · chocolatey/choco
That made me realise that for large groups of English speaking people “smarter than the average bear” would actually be a well known thing.
So I searched and learned a thing or two:
Posted in .NET, Chocolatey, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Leave a Comment »
Posted by jpluimers on 2023/05/17
A while ago, I needed the file information of wsl.exe on one of my Windows systems.
On Linux, I would do something like file `which bash` where file will give the file details and which gets you the full path to bash.
The file equivalent on Windows for me is [Wayback/Archive] Sigcheck – Windows Sysinternals | Microsoft Docs, which is part of [Wayback/Archive] File and Disk Utilities – Windows Sysinternals | Microsoft Docs.
The which equivalent on Windows for me is [Wayback/Archive] where | Microsoft Docs.
Posted in bash, Batch-Files, CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | 1 Comment »
Posted by jpluimers on 2023/05/10
Sometimes, you want to restart the Windows explorer. This is already an exception case which you want to do when explorer hangs (for instance when taskbar icons do not respond any more), or has files locked which need to be modified. I described the latter in Inno Setup: Program Folder not showing up In Start > All Programs , with this very simple restart script:
taskkill /F /IM explorer.exe start explorer
Even more exception is wanting to run explorer with a UAC elevated administrative token. I sometimes do this when moving around stuff from other users on the same computer without having them logged on (as that would lock the files or directories to be moved around).
The risk of running explorer under UAC elevation, is that any program you start will also start UAC elevated, so beware what you ask for…
This is how you start explorer under UAC elevation:
pwsh.exe -nol -noni -nop -w hidden -c "taskkill /f /im explorer.exe; start explorer -v runas -a /nouaccheck"
or if you run an older Windows version of PowerShell:
PowerShell.exe -nol -noni -nop -w hidden -c "taskkill /f /im explorer.exe; start explorer -v runas -a /nouaccheck"
These command-line options and verbs are used:
pwsh == PowerShell:
-nol == -NoLogo-noni == -NonInteractive-nop == -NoProfile-w hidden == -WindowStyle Hidden *-c == -CommandSee:
taskkill:
/F == force close/IM == image name (name of .exe file)start == [Wayback/Archive] Start-Process (Microsoft.PowerShell.Management) – PowerShell | Microsoft Docs
-v == -Verb (in this case runas*)-a == -ArgumentList (to explorer)See [Wayback/Archive] Start-Process (Microsoft.PowerShell.Management) – PowerShell | Microsoft Docs.
explorer
/nouaccheck == /NoUACCheck**Time to explain a few:
Posted in Batch-Files, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows, Windows 10, Windows 11, Windows 7, Windows 8.1 | 1 Comment »
Posted by jpluimers on 2022/10/26
With APIs, you always hope that Get and Set methods mirror each other. More often than not, they don’t.
Take for instance these two:
Get-NetFirewallRule (NetSecurity) | Microsoft DocsSet-NetFirewallRule (NetSecurity) | Microsoft DocsThey are far from symmetric: [Wayback/Archive] Get-NetFirewallRule shows far less than [Wayback/Archive] Set-NetFirewallRule allows you to set (first and foremost the various port related properties). It can be worked around though.
There are a few posts discussing this, of which I think these two are the most important:
Both above posts via [Wayback/Archive] “Get-NetFirewallRule” “LocalPort” – Google Search.
This is what I was after:
PowerShell "Get-NetFirewallRule -Name 'RemoteDesktop-UserMode-In-TCP' | Select-Object Name,DisplayName,Enabled,Direction,@{Name='Protocol';Expression={($PSItem | Get-NetFirewallPortFilter).Protocol}},Action,@{Name='LocalPort';Expression={($PSItem | Get-NetFirewallPortFilter).LocalPort}}"
Or actually:
Posted in CommandLine, Development, Power User, PowerShell, PowerShell, Remote Desktop Protocol/MSTSC/Terminal Services, Scripting, Software Development, Windows | 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:
conhost.exe and condrv.sys, and the core everything is a file/object difference in the unix and Windows world)
- Keep the default value of ‘termwintype’ as “”.
- If ‘termwintype’ is “” and if ConPTY is considered stable (Win10 1903? or later), use ConPTY.
- If ‘termwintype’ is “” and if ConPTY is considered unstable (1809), use winpty.
- If ‘termwintype’ is “” and if ConPTY is not available (before 1809), use winpty.
- If ‘termwintype’ is “conpty”, use ConPTY even if it is unstable (1809).
- If ‘termwintype’ is “winpty”, use winpty.
conhost.exe)–jeroen
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/07/06
Early june, I blogged about Wake-on-LAN from a Windows machine.
My plan was to adopt [Wayback/Archive.is] Wake.ps1 into Wake-on-LAN.ps1 (as naming is important).
One of the goals was to support multiple hardware MAC address formats, especially as Wake.ps1 had the below comment, but did support the AA-BB-CC-DD-EE-FF, though not the AA:BB:CC:DD:EE:FF hardware MAC address format:
<# ... .NOTES Make sure the MAC addresses supplied don't contain "-" or ".". #>
A colon separated hardware MAC address would result in this error inside the call to the [Wayback/Archive.is] PhysicalAddress.Parse Method (System.Net.NetworkInformation) | Microsoft Docs:
Send-Packet : Exception calling "Parse" with "1" argument(s): "An invalid physical address was specified."
So I did some digging, starting inside the above mentioned blog post, and adding more:
Parse method in the [Wayback/Archive.is] PhysicalAddress.cs source code in C# .NET, which contains code like this://has dashes? if (address.IndexOf('-') >= 0 ){ hasDashes = true; buffer = new byte[(address.Length+1)/3]; }
xx:xx:xx:xx:xx:xx(canonical)xx-xx-xx-xx-xx-xx(Windows)xxxxxx-xxxxxx(Hewlett-Packard switches)xxxxxxxxxxxx(Intel Landesk)
I should rename the first one IEEE 802, as per this:
The standard (IEEE 802) format for printing EUI-48 addresses in human-friendly form is six groups of two hexadecimal digits, separated by hyphens (
-) in transmission order (e.g.01-23-45-67-89-AB). This form is also commonly used for EUI-64 (e.g.01-23-45-67-89-AB-CD-EF).[2] Other conventions include six groups of two hexadecimal digits separated by colons (:) (e.g.01:23:45:67:89:AB), and three groups of four hexadecimal digits separated by dots (.) (e.g.0123.4567.89AB); again in transmission order.[30]
The latter is used by Cisco (see for instance [Wayback/Archive.is] Cisco DCNM Security Configuration Guide, Release 4.0 – Configuring MAC ACLs [Support] – Cisco and [Wayback/Archive.is] Cisco IOS LAN Switching Command Reference – mac address-group through revision [Support] – Cisco), so another format to add:
xxxx.xxxx.xxxx(Cisco)
The
addressparameter must contain a string that can only consist of numbers and letters as hexadecimal digits. Some examples of string formats that are acceptable are as follows:
00112233445500-11-22-33-44-550011.2233.445500:11:22:33:44:55F0-E1-D2-C3-B4-A5f0-e1-d2-c3-b4-a5Use the GetAddressBytes method to retrieve the address from an existing PhysicalAddress instance.
I really do not have all the sources for the various representations for 48-bit MAC addresses, but I have seen them variously used:
AA-BB-CC-DD-EE-FF AA.BB.CC.DD.EE.FF AA:BB:CC:DD:EE:FF AAA-BBB-CCC-DDD AAA.BBB.CCC.DDD AAA:BBB:CCC:DDD AAAA-BBBB-CCCC AAAA.BBBB.CCCC AAAA:BBBB:CCCC AAAAAA-BBBBBB AAAAAA.BBBBBB AAAAAA:BBBBBB
From the last list, which is far more complete than the others, I recognise quite a few from tools I used in the past, but too forgot the actual sources, so I took the full list from there and tried to name them in parenthesis after the links I found above and what I remembered:
AABBCCDDEEFF (Bare / Landesk)AA-BB-CC-DD-EE-FF (IEEE 802 / Windows)AA.BB.CC.DD.EE.FF (???)AA:BB:CC:DD:EE:FF (Linux / BSD / MacOS)AAA-BBB-CCC-DDD (???)AAA.BBB.CCC.DDD (Cisco?)AAA:BBB:CCC:DDD (???)AAAA-BBBB-CCCC (???)AAAA.BBBB.CCCC (Cisco / Brocade)AAAA:BBBB:CCCC (???)AAAAAA-BBBBBB (Hewlett-Packard networking)AAAAAA.BBBBBB (???)AAAAAA:BBBBBB (???)Some additional links in addition to the ones above:
–jeroen
Posted in .NET, CommandLine, Development, Encoding, HEX encoding, Network-and-equipment, Power User, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »