Archive

Posts Tagged ‘Windows’

HowTo: Use WSL2 with Docker Desktop instead of Hyper-V backend

At installation guide of Docker Desktop one reads:

Containers and images created with Docker Desktop are shared between all user accounts on machines where it is installed. This is because all Windows accounts use the same VM to build and run containers. Note that it is not possible to share containers and images between user accounts when using the Docker Desktop WSL 2 backend.

That note on WSL2 is written in a negative tone, but is probably a plus security-wise. Anyway their WSL2 based engine provides better performance that then legacy Hyper-V backend Docker Desktop was only providing in the past, so one should opt for that.

Apart from the instructions in the installation guide mentioned above, a quick way to check if it is set to use the WSL2 based engine is via the context menu from taskbar tray icon of Docker Desktop to go to Settings and in General section check the value of “Use the WSL 2 based engine”.

clip_image001

clip_image002

clip_image003

HowTo: Reboot remote Windows computer with unresponsive RDP

I recently had an issue with an older Windows Server 2008 R2 server that couldn’t logout which had resulted to Remote Desktop not connecting to it anymore (not even with the “admin session” option). Luckily I had an admin go and physically cycle its power since it was a physial one without any lower level control available.

When the same issue occured at its twin machine, I decided before asking for another physical intervention to first try various other ways to reboot it remotely (e.g. via Windows Shutdown command and via the Computer Management console), but to no avail.

Eventually what worked was SysInternals PsShutdown tool. The syntax I used was:

PsShutdown –u AdminUserName –p AdminPassword –f –r \\MachineIPaddress

According to its command-line reference:

-u
Specifies optional user name for login to remote computer.

-p
Specifies optional password for user name. If you omit this you will be prompted to enter a hidden password.

-f
Forces all running applications to exit during the shutdown instead of giving them a chance to gracefully save their data.

-r
Reboot after shutdown.

I could maybe have used

-o
Logoff the console user.

instead of –r, but it didn’t help when I first tried without the –f option.

Guess if I had passed –f too in the first place with –o it might have worked, but it never hurts to do a reboot, unless you have any critical services you’re not sure will restart correctly. However, I would worry more about such a thing on a Unix machine rather than on a Windows one where periodic rebooting usually gives a “breath of fresh air” to the OS.

Most probably some application was preventing logoff, however I’d expect Remote Desktop / Terminal Service to be more robust in such a case.

HowTo: install multiple Corel Painter brushpacks silently

I got a nice expression software charity bundle with Corel Painter 2020 (current version is 2021) and a bunch of brushes in it and then noticed that the brush packs where available for download as separate installers than the Painter software.

So I launched one of the brush pack installers from the command-line (can give CMD and press enter at the address bar of the file explorer window to open command-line in the current folder) with a /? parameter to see its syntax:

e:\brushpack_abstract_windows.exe /?

image

Then I created a batch file to loop over all the brush_* installer files using the following commands in the console (press ENTER after each one). The for loop executes each brush pack installer from the same folder passing parameters for silent mode (/S /v/qn), as instructed by the dialog above:

copy con PainterInstallBrushes.bat
@for %%f in (brushpack_*) do %%f /S /v/qn

^Z

The last one (^Z) means Press CTRL+Z (then press ENTER for that line too). It signifies the end-of-file / input. We were inputing/copying keystrokes from the console (CON) into the file PainterInstallBrushes.bat (note that if the file exists you’re asked to overwrite it as soon as you copy the 1st line into it, but you still have to press CTRL+Z and ENTER to end input).

To avoid having to press Yes at repeated security dialogs (due to User Access Control [UAC] being activated), I opened an administrator command-prompt (can give CMD at Windows search and right click the found cmd.exe and select to open it as administrator), then executed the batch file (E: goes to drive E, CD \Corel.com goes to Corel.com folder under E: drive root)

c:\windows\system32> e:
e:\somefolder> cd \Corel.com
e:\Corel.com> PainterInstallBrushes.bat

e:\Corel.com>PainterInstallBrushes.bat

e:\Corel.com>brushpack_abstract_windows.exe /S /v/qn

e:\Corel.com>brushpack_alcoholink_windows.exe /S /v/qn

e:\Corel.com>brushpack_bristly_windows.exe /S /v/qn

e:\Corel.com>brushpack_bubbles_windows.exe /S /v/qn

e:\Corel.com>brushpack_drytexture_windows.exe /S /v/qn

e:\Corel.com>brushpack_feather_windows.exe /S /v/qn

e:\Corel.com>brushpack_fireworks_windows.exe /S /v/qn

e:\Corel.com>brushpack_gesturalillustration_windows.exe /S /v/qn

e:\Corel.com>brushpack_mangaii_windows.exe /S /v/qn

e:\Corel.com>brushpack_michellewebbmasterpack_windows.exe /S /v/qn

e:\Corel.com>brushpack_nature_windows.exe /S /v/qn

e:\Corel.com>brushpack_perfectpets_windows.exe /S /v/qn

e:\Corel.com>brushpack_popart_windows.exe /S /v/qn

e:\Corel.com>brushpack_rain_windows.exe /S /v/qn

e:\Corel.com>brushpack_rake_windows.exe /S /v/qn

e:\Corel.com>brushpack_rustandpatina_windows.exe /S /v/qn

e:\Corel.com>brushpack_scrape_windows.exe /S /v/qn

e:\Corel.com>brushpack_stipple_windows.exe /S /v/qn

e:\Corel.com>brushpack_suminagashi_windows.exe /S /v/qn

e:\Corel.com>brushpack_sunnyrays_windows.exe /S /v/qn

An alternative way to using the command-line would have been to create the batch (.bat) file with a text editor in the same folder as the brush pack installers, then right click it and select to run it as an administrator from the popup menu.

HowTo: Install Python, PIP and cx_Oracle on MSYS2 / Windows

Here’s how to install Python, PIP package installer and cx_Oracle extension module on MSYS2:

$ pacman -S python
warning: python-3.8.3-1 is up to date — reinstalling
resolving dependencies…
looking for conflicting packages…

Packages (1) python-3.8.3-1

Total Installed Size:  108.66 MiB
Net Upgrade Size:        0.00 MiB

:: Proceed with installation? [Y/n] y

$ pacman -S cx_Oracle
error: target not found: cx_Oracle

$ pip install cx_Oracle
bash: pip: command not found

$ pacman -S python-pip
resolving dependencies…
looking for conflicting packages…

Packages (2) python-setuptools-47.1.1-1  python-pip-20.1.1-1

Total Download Size:    2.22 MiB
Total Installed Size:  10.91 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages…

$ pip install cx_Oracle
Collecting cx_Oracle
  Downloading cx_Oracle-8.0.0.tar.gz (325 kB)
     |████████████████████████████████| 325 kB 693 kB/s
Using legacy setup.py install for cx-Oracle, since package ‘wheel’ is not installed.
Installing collected packages: cx-Oracle
    Running setup.py install for cx-Oracle … error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.exe -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-wqtzv2rv/cx-Oracle/setup.py’"’"’; __file__=’"’"’/tmp/pip-install-wqtzv2rv/cx-Oracle/setup.py’"’"’;f=getattr(tokenize, ‘"’"’open’"’"’, open)(__file__);code=f.read().replace(‘"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, __file__, ‘"’"’exec’"’"’))’ install –record /tmp/pip-record-mui2mjs9/install-record.txt –single-version-externally-managed –compile –install-headers /usr/include/python3.8/cx-Oracle
         cwd: /tmp/pip-install-wqtzv2rv/cx-Oracle/
    Complete output (17 lines):
    running install
    running build
    running build_ext
    building ‘cx_Oracle’ extension
    creating build
    creating build/temp.msys-3.1.5-x86_64-3.8
    creating build/temp.msys-3.1.5-x86_64-3.8/src
    creating build/temp.msys-3.1.5-x86_64-3.8/odpi
    creating build/temp.msys-3.1.5-x86_64-3.8/odpi/src
    x86_64-pc-msys-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -march=x86-64 -mtune=generic -O2 -pipe -march=x86-64 -mtune=generic -O2 -pipe -DCXO_BUILD_VERSION=8.0.0 -Iodpi/include -Iodpi/src -I/usr/include/python3.8 -c src/cxoApiType.c -o build/temp.msys-3.1.5-x86_64-3.8/src/cxoApiType.o
    In file included from src/cxoModule.h:14,
                     from src/cxoApiType.c:11:
    /usr/include/python3.8/Python.h:44:10: fatal error: crypt.h: No such file or directory
       44 | #include <crypt.h>
          |          ^~~~~~~~~
    compilation terminated.
    error: command ‘x86_64-pc-msys-gcc’ failed with exit status 1
    —————————————-
ERROR: Command errored out with exit status 1: /usr/bin/python3.exe -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-wqtzv2rv/cx-Oracle/setup.py’"’"’; __file__=’"’"’/tmp/pip-install-wqtzv2rv/cx-Oracle/setup.py’"’"’;f=getattr(tokenize, ‘"’"’open’"’"’, open)(__file__);code=f.read().replace(‘"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, __file__, ‘"’"’exec’"’"’))’ install –record /tmp/pip-record-mui2mjs9/install-record.txt –single-version-externally-managed –compile –install-headers /usr/include/python3.8/cx-Oracle Check the logs for full command output.

Found a solution here for other Linuxes, mentioning

apt install python-dev clang libcrypt-dev

Via MSYS2 package manager (pacman), libcrypt and libcrypt-devel seem to be available. The second one should fetch the first one if needed, together with header files for development.

$ pacman -S libcrypt-devel
resolving dependencies…
looking for conflicting packages…

Packages (1) libcrypt-devel-2.1-2

Total Download Size:   0.04 MiB
Total Installed Size:  0.04 MiB

:: Proceed with installation? [Y/n] y

Now we can install cx_Oracle succesfully:

$ pip install cx_Oracle
Collecting cx_Oracle
  Using cached cx_Oracle-8.0.0.tar.gz (325 kB)
Using legacy setup.py install for cx-Oracle, since package ‘wheel’ is not installed.
Installing collected packages: cx-Oracle
    Running setup.py install for cx-Oracle … done
Successfully installed cx-Oracle-8.0.0

Using cross-platform fswatch utility for monitoring file system changes

I was just looking for a way to monitor for file system changs in a cross-platform way.

After searching the answers at a related question on StackExchange and the ones at the other question mentioned as possible duplicate in that question’s comments, I think I’d go with fswatch since it is has cross-platform support. Contributed the following answer to collect info I gathered on fswatch.

It uses different kinds of monitors for different OS and can choose the appropriate one automatically, or allow one to specify which one to use and even pass custom platform-specific parameters to the respective monitor.

The list of monitors it currently supports is:

· A monitor based on the File System Events API of Apple OS X.

· A monitor based on kqueue, an event notification interface introduced in FreeBSD 4.1 and supported on most *BSD systems (including OS X).

· A monitor based on inotify, a Linux kernel subsystem that reports file system changes to applications.

· A monitor based on File Events Notification, a Solaris/Illumos kernel API that reports file events.

· A monitor based on ReadDirectoryChangesW, a Microsoft Windows API that reports changes to a directory.

· A monitor which periodically stats the file system, saves file modification times in memory and manually calculates file system changes, which can work on any operating system where stat (2) can be used.

It seems to be available via apt-get on Debian/Ubuntu Linuxes. See how to install via apt-get and use fswatch.

FreeBSD and OS-X package-based installation support for fswatch is provided by its author.

Can also build and install it at other OSes, found an article+video showing how to make and install fswatch on CentOS.

There is also an other article that shows the same manual process to build/install (and use) fswatch for Linux.

Windows-based package-based installation support doesn’t seem to be available yet (e.g. no package for Chocolatey yet, and no package for Vcpkg)

There is also extensive documentation for fswatch, though docs for the latest 1.5 version point to 1.4 ones currently. See how to convert commands for fswatch 0.x to fswatch 1.x

Tips for manually choosing a monitor (currently not updated to mention all monitors)

Read about fswatch usage here, here and here and a tutorial intro here

A library named libfswatch is kept in sync with the fswatch tool. See here and a newer doc here. Note that the library is versioned differently from fswatch utility itself. Specifically, the 1.14.0 library doc states:

"libtool’s versioning scheme is described by three integers: current:revision:age.

· current is the most recent interface number implemented by the library.

· revision is the implementation number of the current interface.

· age is the difference between the newest and the oldest interface that the library implements.

Beware that there is also another similar s/w called fswatch (that is go-related I think).

Python rstrip and whitespace

Was just reading

https://www.w3schools.com/python/ref_string_rstrip.asp

which says

The rstrip() method removes any trailing characters (characters at the end a string), space is the default trailing character to remove.

Notes:

1) the chars param was added at Python 2.2.3, can’t use it at older versions as noted at

https://docs.python.org/2.6/library/string.html

string.rstrip(s[, chars])
Return a copy of the string with trailing characters removed. If chars is omitted or None, whitespace characters are removed. If given and not None, chars must be a string; the characters in the string will be stripped from the end of the string this method is called on.

Changed in version 2.2.3: The chars parameter was added. The chars parameter cannot be passed in earlier 2.2 versions.

2) from the official doc and other docs too I read the default is to remove whitespace characters, not just the space char:

https://python-reference.readthedocs.io/en/latest/docs/str/rstrip.html

chars
Optional. String specifying the set of characters to be removed. If omitted or None, the chars argument defaults to removing whitespace. The chars argument is not a prefix; rather, all combinations of its values are stripped.

Not sure what is considered whitespace in various Python versions though. At least in Python2 it wasn’t removing \r in both Solaris and MSYS2 (a POSIX environment on Windows) where I just tried.

For example, I was just debugging some program that was working in Python 3, but in Python 2 it was moving the cursor to the start of the line when printing a raw_input prompt with some string it had read before…
…the issue proved to be that it was opening a file with ‘r’ mode instead of ‘rU’ which is universal newlines mode – https://www.python.org/dev/peps/pep-0278/ – converts \r\n to \n – and it seems that rstrip was failing to remove the \r from the end of those strings.

In Python 3 it was either using the universal newlines mode by default and thus stripping the \r from strings while reading from the file, or the rstrip was removing \r too in Python3, but I guess it was the 1st case (didn’t do any more check since the universal newlines read file open mode fixed the issue in Python 2 for me).

Speaking of that, I wonder whether Python considers whitespace differently on Windows and on Unixes (aka having [l/r]strip commands remove \r on the 1st but not on the 2nd case), which would be an extra complexity when writing portable s/w.

HowTo: Use DISM and SFC tools to check+fix your Windows installation

If you’re having issues with your Windows 7 or newer, you should consider whether its installation has become corrupted (due to malicious software or hard drive errors).

After doing a disk check (say by right clicking the appropriate drive under my computer and selecting Properties, then Tools tab and Error checking) and a complete virus scan (on Win10 you can click the shield icon of Windows defender in the taskbar tray and at scanning options choose to do a full scan – or if you have installed some third-party antivirus double-click its icon in the taskbar tray and when its GUI opens up opt to do a full scan), then try the following steps to repair your Windows installation:

1. Press WIN+R to open Run dialog

2. Type in:

CMD

Hold down CTRL+SHIFT keys and click OK to open the command line window in Administrator mode (do press Yes at the User Account Control prompt)

A (usually) black text-based console window will open up and you’ll be greated with something like:

Microsoft Windows [Version 10.0.18363.720]
(c) 2019 Microsoft Corporation. All rights reserved.

and then a prompt like:

C:\Windows\system32>

3. Type in the following and press the ENTER key:

DISM.exe /Online /Cleanup-image /Scanhealth

and press ENTER to execute the DISM tool with the option to check the windows image health and wait patiently for it to complete

Deployment Image Servicing and Management tool
Version: 10.0.18362.1

Image Version: 10.0.18363.720

[==========================100.0%==========================] The component store is repairable.
The operation completed successfully.

4. In case you see a message that the component store is repairable, then when greeted with the C:\Windows\system32> prompt again, type in the following and press ENTER:

DISM.exe /Online /Cleanup-image /RestoreHealth

to repair the Windows image:

Deployment Image Servicing and Management tool
Version: 10.0.18362.1

Image Version: 10.0.18363.720

[==========================100.0%==========================] The restore operation completed successfully.
The operation completed successfully.

If RestoreHealth fails and you’re on Windows 10, then you should checkout this article:

https://www.tenforums.com/tutorials/16397-repair-install-windows-10-place-upgrade.html

on how to do an in place upgrade of Windows 10, opting to keep your settings and apps

5. If all goes well you’ll see that the restore operation completed successfully and you’ll be taken again to the command-line prompt C:\Windows\system32>

Now that the windows image is checked and fine, you should check your Windows installation against that image, giving the following command and pressing ENTER:

sfc /scannow

Beginning system scan.  This process will take some time.

Beginning verification phase of system scan.
Verification 100% complete.

Windows Resource Protection found corrupt files and successfully repaired them.
For online repairs, details are included in the CBS log file located at
windir\Logs\CBS\CBS.log. For example C:\Windows\Logs\CBS\CBS.log. For offline
repairs, details are included in the log file provided by the /OFFLOGFILE flag.

After any automatic repairs you should see the prompt C:\Windows\system32> again. Now repeat the same step till you see no more errors found and repaired.

sfc /scannow

Beginning system scan.  This process will take some time.

Beginning verification phase of system scan.
Verification 100% complete.

Windows Resource Protection did not find any integrity violations.

When back at the C:\Windows\system32> prompt with no errors found and repaired, just close the console window or type in the following and press ENTER:

exit

Fix: make ownCloud installer display in English language

OwnCloud is an interesting solution for setting up a file sharing cloud for a group of people.

However,one issue I’ve found with its Windows desktop client’s current version (which looks clean of any viruses since I always check first) is that if your Windows 10 is configured with a preferred language that the desktop client’s installer doesn’t have localization support for, then it doesn’t show up in English as you’d expect, but in Czech or someother language that most of us don’t know how to read.

Screenshot (493)

So I tried running it’s MSI installer (ownCloud-2.6.1.13407.13049.msi) with –? parameter from the command-line and the /g languageCode parameter mentioned there looked promising, but trying /g en for English didn’t work. I guessed it needed some specific language code number (and not double-letter language code like en for English), since the help text was mentioning to see Windows Installer SDK for more help.

After a quick search I found an article that suggested passing the parameter Productlanguage=1033 to an msi installer on the command-line for it to ALWAYS show in English. And indeed it worked.

Screenshot (494)

To open a command window one can click the Search icon on the windows taskbar and type CMD then press ENTER.

Then they can drag-drop the .MSI file of ownCloud installer onto the black command-line window that opens up and type an extra space char and then Productlanguage=1033 before pressing ENTER to launch the ownCloud installer in English. After that they can close the command-line window at anytime.

Since many users may be uncomfortable with such instructions, one could provide an msiEnglish.bat file that just contains

%1 Productlanguage=1033

User could drag-drop the .msi they want onto that msiEnglish.bat file and it would run the msi installer being displayed in English language, irrespective of any preferred language settings at the Windows operating system.

Of course the best thing would be if ownCloud fixed their desktop client installer to fallback to the Engish language (set it as default) if it can’t find localization strings for the currently prefered language of the user. Have filed an issue at https://github.com/owncloud/client/issues/7825

Fix: Buildbox activation issues on load

Buildbox is a wonderful game authoring tool (that spans the whole nocode-code continuum, including the low-code aspect). It now has a free version too with nice templates and tutorials included.

image

I had an issue with the Windows version (it also has an indentical MacOS-X version since it’s a Qt-based app) where it was complaining about activation issue at startup and couldn’t proceed.

To solve that you can remove activation info (which won’t be removed if you just do uinstall and reinstall) by deleteing the com.eightcell.buildbox subfolder at:

C:\Users\YOUR_PROFILE_NAME_HERE\AppData\Local\eightcell\Buildbox\

Next time you run Buildbox.exe it will show activation dialog and you can enter your registration key (even the free version has one that you can download from your free account at http://buildbox.com)

With the latest Buildbox 3 there seems to exist an extra com.eightcell.buildbox3 subfolder that you could delete or just rename the main.iblicense files in there to main._iblicense. The launch Buidlbox again to see the activation dialog.

image

There probably exists some bug in Buildbox that causes one to repeat this action often.
So you could add a RESET_BUILDBOX_LICENSE.BAT file to your desktop with the following commands to delete the license file:

del "%AppData%\..\Local\eightcell\Buildbox\com.eightcell.buildbox3\main.iblicense"
@pause

HowTo: Fix DVD/CD with Live filesystem (Packet/UDF) on Windows

The other day I found how easy it is to use a Live CD/DVD (where packet writing occurs when adding stuff) instead of a Mastered one (where all is kept to be written when you close the disk) on Windows.

It feels more like using a USB flash disk and should be more safe regarding losing data in the long run if you want to keep some file archive. In theory at least, since there are cases the live disk last write operation may fail and it may appear as an unreadable disk after one, making funny noises when you insert it and freezing for long time periods Windows Explorer when you try to access it.

However, the UDF filesystem that it uses keeps multiple VAT tables for the blocks written to the disk, which means it can be restored to the last workable state of the disk (you might still lose data from the last block I guess, but you’ll have access to the rest of the files you had written to the disk). For any files you find missing, you can try file recovery software with deep search option, like ISOBuster.

To restore such a disk back to working state, on Windows 10 you can right click the Start menu button and from the context (popup) menu shown, you can select to run PowerShell as Administrator. Then you can write CMD and press ENTER. The classic command-line shell (DOS syntax) will open up, where you should type-in chkdsk /f e: (replacing e: with the letter of the drive where the problematic disk has been inserted – can find that one easily from Windows Explorer / My Computer) and press ENTER again.

The disk should be detected as being of UDF format and the disk checking (chkdsk) command will check for a valid VAT on the last written block and if it can’t will try to revert the media to a previous state, before the corruption occurred by placing at the the end of the disk the last valid VAT.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\WINDOWS\system32> cmd
Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. Με επιφύλαξη κάθε νόμιμου δικαιώματος.

C:\WINDOWS\system32>chkdsk /f e:
The type of the file system is UDF.
Volume Μουσική is UDF version 2.01.

Chkdsk is running on media that does not support writes in place.
On such media chkdsk operation is limited to verifying the presence
of a valid VAT on the last written block and if necessary searching
for the last valid VAT and placing it at the end of the disk.
This could revert the media to a previous state before the corruption
occured.

Chkdsk could not find a valid VAT at the end of the volume.

CHKDSK is searching for a valid VAT …

And after some ages (stayed at 0% for some time and then took around a day progressing slowly on my machine for a DVD) you’ll hopefully see something like:

Search for VAT completed.
Chkdsk is copying last valid VAT at block 1722719 to the end of the
volume. This will revert the volume to its state at 01:13 on
10/09/2018.

Windows has made corrections to the file system.
No further action is required.

   4595200 KB total disk space.
    222240 KB available on disk.

      2048 bytes in each allocation unit.
   2297600 total allocation units on disk.
    111120 allocation units available on disk.

Then type exit followed by ENTER key twice to exit the command processor (cmd) and PowerShell. This will close the console window.

C:\WINDOWS\system32>exit
PS C:\WINDOWS\system32> exit

Enjoy your disk with its files again, hopefully all of them… Plus you’ll be able to add more files to the disk, which could have even been near to empty when the corruption had occurred. Note that when you’re finished and don’t want to write anymore files to the disk, you can right click it and close the session, so that it can be readable on more systems.

%d bloggers like this: