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 1,525 other followers

Archive for the ‘Windows’ Category

Run cmd as elevated user (via: windows – How to run batch file command with elevated permissions? – Super User)

Posted by jpluimers on 2019/03/13

Based on [WayBack] windows – How to run batch file command with elevated permissions? – Super User:

powershell -command "Start-Process cmd.exe -Verb runas"

This works better than "runas /user:administrator cmd.exe" as that forces to use the specific Administrator account, whereas the PowerShell way allows you to specify the actual account during elevation.


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

How do I export the history from the Windows command line to a text file? – Super User

Posted by jpluimers on 2019/03/11

I totally did not know that DOSKEY was part of CMD.EXE, but it is: [WayBack] How do I export the history from the Windows command line to a text file? – Super User

Even better: it can export the command history:

doskey /HISTORY > history.txt



Posted in Console (command prompt window), Power User, Windows | Leave a Comment »

sorting – Is there a Windows equivalent to the Unix uniq? – Super User

Posted by jpluimers on 2019/03/08


  • Windows 10 has an undocumented /unique switch for sort
  • git for Windows ships with uniq (in a default x64 install, it is at C:\Program Files\Git\usr\bin\uniq.exe)

From [WayBack] sorting – Is there a Windows equivalent to the Unix uniq? – Super User

This works fine:

dir /s /b *0*.pas *1*.pas *2*.pas *3*.pas *4*.pas *5*.pas *6*.pas *7*.pas*8*.pas *9*.pas | sort /unique > pas-files-with-numeric-names.txt

I need remove duplicate lines from a text file, it is simple in Linux usingcat file.txt |sort | uniqwhen file.txt containsaaabbbaaacccIt will output aaabbbcccIs there a Windows


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

Windows 10: force to sleep at night, but allow wake up for Windows Updates

Posted by jpluimers on 2019/03/04

I do not like a machine that sleeps after a certain amount of inactivity as I might have a long running job going on.

Usually however, I do like to have a machine off at night, even if I forget to put it asleep.

Exceptions for sleeping are just two:

  • automatic back-up schedule
  • allowing Windows Updates

Luckily you can tell Windows 10 to allow for all cases.

Enabling wake-up during Windows Updates

Note I’m not fully sure which BIOS settings you need to enable – if any- to have this work on all systems. Wake up works on my machine for these [WayBackpsshutdown parameter combinations:

  • psshutdown.exe -h -t 0 (Hibernate)
  • psshutdown.exe -d -t 0 (Suspend)

It fails with these:

  • psshutdown.exe -s -t 0 -f (Shutdown without poweroff)
  • psshutdown.exe -k -t 0 (Poweroff)

The odd thing: Wake-on-LAN can usually wake up the last two.

This is done with the gpedit.msc (via [WayBackHow to prevent Windows 10 waking from sleep when traveling in bag? – Super User, thanks xxxbence)

Follow this path:

  1. Local Computer Policy
  2. Computer Configuration
  3. Administrative Templates
  4. Windows Components
  5. Windows Update

Double click Enabling Windows Update Power Management to automatically wake up the system to install scheduled updatesto show the below dialog.

Enable it:

so it looks like this:

Forcing sleep (in my case hibernate) using the Task Scheduler

In Windows 7..10: disable shutdown/hibernate/sleep/restart from UI I wrote about shutdown /h /f to hibernate a machine. You can force to run this from the taskschd.msc (Windows Task Scheduler):

I wanted history for tasks, so I started taskschd.msc as Administrator, then on the right Actions Pane, I clicked on Enable All Tasks History:

 also explained in [WayBackHow can I enable the Windows Server Task Scheduler History recording? – Stack Overflow and can be verified/set on the console as well:

  • Get as any user: wevtutil get-log Microsoft-Windows-TaskScheduler/Operational
  • Set as Administrator: wevtutil set-log Microsoft-Windows-TaskScheduler/Operational /enabled:true

I named the task __ sleep at 2300 with these settings:

Ensure the Program/script itself is shutdown and the parameters are /h /f:


Posted in Power User, Windows, Windows 10 | Leave a Comment »

Windows 10: mounting an ISO to a specific drive letter and keeping that drive letter after boot

Posted by jpluimers on 2019/03/01

I tried finding a way with the built-in Windows tools to keep an ISO mounted to a specific drive letter (some software remembers the drive letter it got installed from and disallows changing it).

I couldn’t. Luckily there is WinCDEmu which supports more formats than the built-in Windows tools as well.

[WayBackWinCDEmu – How to keep images mounted

  1. Right click the ISO file
  2. Choose Select drive letter & mount
  3. In the popup dialog, put check marks if you need any of these options:
    • Disable autorun for this time
    • Keep drive after restart

So I can add that to the list of WinCDEmu features I wrote about before (from newer to older):

WinCDEmu is open source; if you want to build it from scratch, you need these repositories:



Posted in Power User, Windows, Windows 10 | Leave a Comment »

%d bloggers like this: