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,860 other subscribers

Archive for the ‘Windows’ Category

Delphi Code Monkey: Cool Advanced Troubleshooting Technique – WinDbg

Posted by jpluimers on 2019/04/11

This so much reminds me of a struggle in the Toshiba Tecra 750CDT era: [WayBack] Delphi Code Monkey: Cool Advanced Troubleshooting Technique – WinDbg.

First about Warren’s issue:

His laptop froze only in Windows 10, but not Windows 7, after doing some debugging work. Display is on, but non-responsive. He ruled out a lot of things, thought it was a video issue, looked for pointers how to research it ending to force memory dumps by keyboard then running WinDbg to further pinpoint the cause.

He solved the issue by removing the Lenovo supplied Intel graphics driver and forcing the Intel HD Graphics 520 OEM drivers onto the system and posted a few interesting links:

Then some history:

Back in the 750CDT days, the problem was the combination of Toshiba using OEM S3 Virge/MX video drivers, Windows GDI and TImageList with a lot of images in them (basically: the component palette).

Result: interrupt freeze of the laptop, so not even mouse or keyword would work.

Solutions:

  • use Windows NT, not Windows 95
  • disable all S3 hardware acceleration
  • use the Toshiba 780 series video drivers

From then on, I’ve never developed on Windows 9x based systems any more, but Windows NT based systems (even though it was much harder to get drivers for all hardware components), this despite the fact that with Windows NT 4, Microsoft video drivers from ring 3 to ring 0 (they were at ring 3 until and including Windows NT 3.51 [Archive.is]). On the one hand the move to ring 0 caused more blue screens, on the other hand made it a lot harder to directly access hardware from user software running at ring 3.

 

–jeroen

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

Call Everything with search pattern as parameter? – voidtools forum

Posted by jpluimers on 2019/03/25

[WayBack] Call Everything with search pattern as parameter? – voidtools forum:

C:\Program Files\Everything\Everything.exe -search """aaa bbb"""

The extra quotes are needed to get through 2 layers of de-quoting.

Related: [WayBack] How to apply quotes from the command line – voidtools forum

–jeroen

Posted in Everything by VoidTools, Power User, Windows | Leave a Comment »

Windows: force a CHKDSK of a non system disk at boot time

Posted by jpluimers on 2019/03/22

Just out of curiosity, I wanted to try run a CHKDSK at boot time of a non-system disk.

The trick appears to be to ensure something locks the drive. An easy way to do that is have a command prompt open inside a directory on that drive.

The below example show just that: a regular command prompt locking the E: drive and an administrative command prompt scheduling the check at boot time:

In text

Regular command prompt:

Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\jeroenp>e:

E:\>cd $RECYCLE.BIN

E:\$RECYCLE.BIN>

Administrative command prompt:

C:\WINDOWS\system32>chkdsk /R /F E:
The type of the file system is NTFS.

Chkdsk cannot run because the volume is in use by another
process.  Chkdsk may run if this volume is dismounted first.
ALL OPENED HANDLES TO THIS VOLUME WOULD THEN BE INVALID.
Would you like to force a dismount on this volume? (Y/N) n

Chkdsk cannot run because the volume is in use by another
process.  Would you like to schedule this volume to be
checked the next time the system restarts? (Y/N) y

This volume will be checked the next time the system restarts.

C:\WINDOWS\system32>

–jeroen

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

How can I open a cmd window in a specific location? – Stack Overflow

Posted by jpluimers on 2019/03/19

Based on [WayBack] How can I open a cmd window in a specific location? – Stack Overflow:

cmd /K "pushd ""D:\Versioned Stuff\wiert.me"""

The quoting is required for paths having spaces, so I always include them just in case I ever have a path with spaces.

If I want it with bash, then I run it as follows:

cmd /K "pushd ""D:\Versioned Stuff\wiert.me""" && "C:\Program Files\Git\bin\bash.exe"

Documentation: [WayBack] CD Change Directory – Windows CMD – SS64.com

–jeroen

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

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.

You can extend this to run a command with one or more parameters based on [WayBack] Launch Elevated CMD.exe from Powershell – Stack Overflow (thanks [WayBack] mklement0):

powershell -command "Start-Process cmd.exe -Verb runas -Args /k, call, goto-bin"

This will actually pass “call goto-bin” to cmd.exe which tries to execute the “goto-bin” command (which I have around on the PATH as goto-bin.bat).

You can either use comma-separated parameters or a quoted string. In this expansion, comma-separated is easier in this PowerShell construct.

–jeroen

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

Related:

–jeroen

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

TL;DR:

  • 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 [WayBack] psshutdown 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 [WayBack] How 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 [WayBack] How 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:

–jeroen

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.

[WayBack] WinCDEmu – 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:

 

–jeroen

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

Windows 10 Feature Focus: Backup and Recovery – Thurrott.com

Posted by jpluimers on 2019/03/01

I totally forgot that the Windows 7/8/8.1. stuff (that makes a back-up to VHD/VHDX) is still in the Control Panel:

While Windows 10 doesn’t actually add any new backup or recovery tools, it provides great upgrades to the tools it previously offered in Windows 7 and 8.

Source: [WayBack] Windows 10 Feature Focus: Backup and Recovery – Thurrott.com

Read the rest of this entry »

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