Windows .bat file command line tool, wait for keypress when double-clicked

Windows .bat files can be a convenient and quick way to automate things, like, for example, a compilation command involving a lot of options. They can be executed from the command line or by double-clicking them from the explorer. In the latter case, one would want the script to wait for a keypress until they close the window. When started from the command line, the waiting from a keypress is rather annoying.

It is possible to make the script behave differently depending on the way it was executed:

IF /I %0 EQU "%~dpnx0" PAUSE

This executes the PAUSE command when the file was started by double-click.

Source: Detect if bat file is running via double click or from cmd window

Starting a local Webserver for Testing

Easiest way is to open a console window in what you would like to have as root directory of your webserver and start

python -m http.server

Then, by serving to http://127.0.0.1:8000 you will be able to view and browse the contents.

To specify a port, just add the port number to the command, for example

python -m http.server 9999

Please not that this webserver does not support https, so you have to enter the URL with a starting http:// and you might have to click away a browser warning because of the unsecured site.

Therefore, only use this for local testing!

Making Screenshots under Windows

To copy a screenshot of the active window into the clipboard: Alt + PrntScrn (Alt + Druck on a German keyboard) Note that the clipboard will be overwritten, so if you want to take two screenshots, you have to paste the first screenshot before taking the second one.

To copy the whole screen into the clipboard: PrntScrn (Druck on a German keyboard)

To make a screenshot with customized clipping, press Winkey + Shift + S.

To save a screenshot of the active window: Alt+ Winkey + PrntScrn (Alt + WinKey + Druck on a German keyboard) The image will be saved in PNG format into the folder Videos\Captures (Videos\Aufzeichnungen on a German Windows)

To save a screenshot of the whole screen: Winkey + PrntScrn (WinKey + Druck on a German keyboard) The image will be saved in PNG format into the folder Pictures\Screenshots (Bilder\Bildschirmfotos on a German Windows)

While it is crazy that two different folders are used for saving the images, other than that the shortkeys are a convenient method to quickly obtain and save screenshots.

View unreachable web pages

There can be several reasons why a webpage is not available. Apart from the obvious server outage, there could be a geo block or a recent deletion of the page.

As long as you are able to get the address of the webpage there is a good chance to retrieve it.

One possibility is to use https://cachedview.com/ which allows to view cached pages from Google web. It is usually updated every few days by google so as long as an article is a couple of days old, you have a good chance accessing it there.

Another option is https://web.archive.org/ which archives copies of webpages including old versions. So if you want to know what was on a certain webpage years ago, archive.org is a good start.

When Windows 10 search suddenly stops working

The search function is a very convenient thing – you press the windows key and start typing, getting displayed the apps or files of interest as you type. For me this feature suddenly stopped working. A renew of the search index, as recommend on several sites did not solve the problem. The troubleshooting program of Windows identified a problem with folder access rights, but this was not the problem. The reason was that the search service was not started anymore for some reason, this might have happened at one of the past updates.

After having the problem identifed, issueing the command searchIndexer.exe /Embedding in an elevated console solved the problem for good.

Fix DPI scaling issues in Windows

If you have a computer with an awesome hi-res display (mine is 3840 x 2160) you might know the problem: some older application don’t follow the DPI upscaling setting of Windows, which makes them in practise unusable.

To fix this issue, you can tell Windows to manually scale up some particular applicatons. To do this, you must first find the place where the application file is located, for example by right-clicking on the program in the start menu:

step1-findfileThen enter the properties page of the file with another right-click:

step2-filepropertiesand tell Windows in the compatibility tab to do the scaling instead of asking the application to do it:

step3-DPIcompatibility