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,726 other followers

Archive for the ‘Batch-Files’ Category

Chocolatey 1.0.0 got released last week (chocolatey/choco · GitHub)

Posted by jpluimers on 2022/03/24

Last week finally there was the stable [Wayback/Archive] Release version 1.0.0 · chocolatey/choco · GitHub.

So I fixed the Wikipedia page

It was a few days after the 11th birthday “Celebration”: [Wayback/Archive] Chocolatey Software Blog | This One Goes To 11! Celebrating 11 Years Of Chocolatey. Not a really festive post, though it does have a really nice overview of 11 years of Chocolatey history and clearly showing the momentum of it has been a few years behind us.

The thing is: hardly anybody noticed the celebration nor the 1.0.0 release. Being at various 0.* versions for like a decade makes people not follow sudden version bumps closely. I only noticed when updating a bunch of testing VMs of which one had a problem, so I inspected the logs and saw the 1.0.0 version.

So these recent tweets did not gain much attention:

Anyway: the release notes indicate a few things scheduled for 2.0.0. Given the sudden 0.12.0 -> 1.0.0 bump, I have no clue far (or near!) in the future that will be.

It is kind of both a saddening and relieved feeling: like for instance Stack Overflow/Stack Exchange (both in the same age cohort as Chocolatey), Chocolatey is just there and mostly works.


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

cd-to-file.bat for when you have a full filename that is too long to truncate by hand

Posted by jpluimers on 2022/01/31

Small cd-to-file.bat tip:

pushd %~dp1


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

windows 7 – How can I eject a CD via the cmd? – Super User

Posted by jpluimers on 2021/12/30

Quite a while ago I found [Wayback] windows 7 – How can I eject a CD via the cmd? – Super User, but forgot to document that in the batch-files I created from it.

It shows both this one-liner:

powershell "(new-object -COM Shell.Application).NameSpace(17).ParseName('D:').InvokeVerb('Eject')"

The hardcoded const 17 is for the ssfDRIVES element in the ShellSpecialFolderConstants, which is documented at [Wayback] ShellSpecialFolderConstants (shldisp.h) – Win32 apps | Microsoft Docs.

There is no PowerShell equivalent of that element, hence the hardcoded value 17.

The script invokes the verb Eject, which works on any kind of removable media (not just optical drives). If you want to limit it to only certain drive types, then you would need to compare the Type of the ParseName() result. However, that result has a Type property returns a string for which the possible values are not documented.

Here are some links I tried to find out what is returned:

In addition to the Shell.Application, there also is Scripting.FileSystemObject, which allows enumerating the drives and filter on DriveType. This is the relevant documentation:

The second example in the above mentioned answer shows how to use this to filter for optical drives.

It also shows a cool technique to have a hybrid batch-file/JScript script:

@if (@CodeSection == @Batch) @then

@echo off

cscript /nologo /e:JScript "%~f0"

goto :EOF

@end // end batch / begin JScript hybrid chimera

// DriveType=4 means CD drive for a WScript FSO object.
// See

// NameSpace(17) = ssfDRIVES, or My Computer.
// See

var oSH = new ActiveXObject('Shell.Application'),
    FSO = new ActiveXObject('Scripting.FileSystemObject'),
    CDdriveType = 4,
    ssfDRIVES = 17,
    drives = new Enumerator(FSO.Drives);

while (!drives.atEnd()) {
    var x = drives.item();
    if (x.DriveType == CDdriveType) {
        oSH.NameSpace(ssfDRIVES).ParseName(x.DriveLetter + ':').InvokeVerb('Eject');
        while (x.IsReady)


Posted in Batch-Files, Development, JScript, PowerShell, Scripting, Software Development | Leave a Comment »

Run the latest RDP session in full-screen

Posted by jpluimers on 2021/12/28

MSTSC.exe helptext

MSTSC.exe helptext

I created this small batch file:

:: start last RDP session (or new one with command-line parameters) full-screen
:: see
mstsc /f %*

It is based on [Wayback] MSTSC Commands and Creating a Custom Remote Desktop Shortcut | InterWorks, which has the helptext for MSTSC.exe (which stands for MicroSoft Terminal Services).

Later I found out a way easier method to get that helptext is to run MSTSC.exe /?, which shows a nice dialog:

[Window Title]
Remote Desktop Connection Usage

MSTSC [] [/v:<server[:port]>] [/g:] [/admin] [/f[ullscreen]] [/w: /h:] [/public] | [/span] [/multimon] [/edit "connection file"] [/restrictedAdmin] [/remoteGuard] [/prompt] [/shadow: [/control] [/noConsentPrompt]]

"connection file" -- Specifies the name of an .RDP file for the connection.

/v:<server[:port]> -- Specifies the remote PC to which you want to connect.

/g: -- Specifies the RD Gateway server to use for the connection. This parameter is only read if the endpoint remote PC is specified with /v.

/admin -- Connects you to the session for administering a remote PC.

/f -- Starts Remote Desktop in full-screen mode.

/w: -- Specifies the width of the Remote Desktop window.

/h: -- Specifies the height of the Remote Desktop window.

/public -- Runs Remote Desktop in public mode.

/span -- Matches the remote desktop width and height with the local virtual desktop, spanning across multiple monitors, if necessary. To span across monitors, the monitors must be arranged to form a rectangle.

/multimon -- Configures the Remote Desktop Services session monitor layout to be identical to the current client-side configuration.

/edit -- Opens the specified .RDP connection file for editing.

/restrictedAdmin -- Connects you to the remote PC in Restricted Administration mode. In this mode, credentials won't be sent to the remote PC, which can protect you if you connect to a PC that has been compromised. However, connections made from the remote PC might not be authenticated by other PCs, which might impact application functionality and compatibility. This parameter implies /admin.

/remoteGuard -- Connects your device to a remote device using Remote Guard. Remote Guard prevents credentials from being sent to the remote PC, which can help protect your credentials if you connect to a remote PC that has been compromised. Unlike Restricted Administration mode, Remote Guard also supports connections made from the remote PC by redirecting all requests back to your device.

/prompt -- Prompts you for your credentials when you connect to the remote PC.

/shadow: -- Specifies the ID of the session to shadow.

/control -- Allows control of the session when shadowing.

/noConsentPrompt -- Allows shadowing without user consent.



Posted in Batch-Files, Development, Power User, Remote Desktop Protocol/MSTSC/Terminal Services, Scripting, Software Development, Windows | Leave a Comment »

Windows: get CPU information on the console

Posted by jpluimers on 2021/12/28

It still seems that WMIC is the quickest way to get CPU information on the console:

T510-PSO C:\bin\rdp> wmic cpu get name,CurrentClockSpeed,MaxClockSpeed
CurrentClockSpeed  MaxClockSpeed  Name
2667               2667           Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz

T510-PSO C:\bin\rdp> wmic path win32_Processor get Name,NumberOfCores,NumberOfLogicalProcessors
Name                                             NumberOfCores  NumberOfLogicalProcessors
Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz  2              4

Actually, wmic cpu is shorthand for wmic path win32_Processor, so this works fine:

T510-PSO C:\bin\rdp> wmic cpu get name,CurrentClockSpeed,MaxClockSpeed,NumberOfCores,NumberOfLogicalProcessors
CurrentClockSpeed  MaxClockSpeed  Name                                             NumberOfCores  NumberOfLogicalProcessors
2667               2667           Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz  2              4

The reason is that cpu is an alias:

T510-PSO C:\bin\rdp> wmic alias cpu list brief
FriendlyName  PWhere              Target
CPU           Where DeviceID='#'  Select * from WIN32_PROCESSOR



Posted in Batch-Files, Console (command prompt window), Development, Power User, Scripting, Software Development, Windows | Leave a Comment »

%d bloggers like this: