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 4,262 other subscribers

Archive for the ‘CommandLine’ Category

My Ultimate PowerShell prompt with Oh My Posh and the Windows Terminal – Scott Hanselman’s Blog

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

Read the rest of this entry »

Posted in CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows, Windows 10, Windows Development | Leave a Comment »

Getting the Chocolatey shimgen generated shim target

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:

Read the rest of this entry »

Posted in Batch-Files, Chocolatey, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Leave a Comment »

Seams I might in part be the cause of (#3186) Remove easter egg “You are smarter than the average bear …” by pauby · Pull Request #3276 · chocolatey/choco

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:

Read the rest of this entry »

Posted in .NET, Chocolatey, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Leave a Comment »

Windows “equivalents” for bash backticks in cmd and PowerShell

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.

Read the rest of this entry »

Posted in bash, Batch-Files, CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | 1 Comment »

Restart Windows explorer with an UAC administrator token

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:

Time to explain a few:

Read the rest of this entry »

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 »