Access Windows Share from Raspberry Pi (revisited)

Last year I described a simple method of automounting a directory from my windows server to my Raspberry Pi. Since then I’ve gone down a couple of paths to simplify rebuilding my Raspberry Pi machines.

The method I used last year required modifying the /etc/hosts file, the /etc/fstab file, pre-creating the mount points, and creating a credentials file to store the windows login credentials.

My new method doesn’t require modification of the /etc/hosts or /etc/fstab files, or pre-creating the mount points. Instead I’m relying on two features, Multicast DNS and systemd.automount unit files.

In the old method, to find the windows server, I added it to the local hosts file on the raspberry pi. Acid

Using Multicast DNS, if I simply recognize that I can reach the server with the name Acid.WimsWorld.local the raspberry pi will find the server on the local network. My first step was to modify my /etc/fstab enty to use the local address and clean up my hosts file.

//acid.wimsworld.local/web /media/acid/web/ cifs credentials=/etc/wimsworld.smb.credentials,noauto,x-systemd.automount,x-systemd.idle-timeout=2min,_netdev 0 0

I’d never been happy with modifying the /etc/fstab file as part of my system configuration because in newer installations it is unique to each machine, specifying the boot partitions by their formatted serial number:

proc            /proc           proc    defaults          0       0
PARTUUID=142ff4e3-01  /boot           vfat    defaults          0       2
PARTUUID=142ff4e3-02  /               ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that

In my recent programming projects I’ve been working with systemd unit files to control my service processes and have come to understand how they work for automounting directories as well. I like that each directory has its own unit files meaning that a modification is less likely to cause problems for the system as a whole.

The single line from the /etc/fstab file above is removed and replaced by two unit files, /etc/systemd/system/media-acid-web.mount and /etc/systemd/system/media-acid-web.automount.

Description=Acid Web




Description=Automount Acid Web



I still had to create the credentials file for this to work, since I wanted the credentials file to be only root readable in a different location. /etc/wimsworld.smb.credentials


After the three files are created, systemd needs to reload its database with the systemctl daemon-reload command, the automount needs to be enabled with the systemctl enable media-acid-web.automount command, and then started with the systemctl start media-acid-web.automount command.

The naming of the mount files is important, and described explicitly in the man pages for each of mount and automount. In my case, /media/acid/web gets named media-acid-web.mount and media-acid-web.automount. I didn’t need to create mount points in the /media directory, as systemd automatically takes care of that.

I was able to create all of the above with a simple paste into my terminal with the following string:

sudo bash
cat > /etc/systemd/system/media-acid-web.mount <<EOF
Description=Acid Web


cat > /etc/systemd/system/media-acid-web.automount <<EOF
Description=Automount Acid Web


cat > /etc/wimsworld.smb.credentials <<EOF
chmod 0600 /etc/wimsworld.smb.credentials
systemctl daemon-reload
systemctl enable media-acid-web.automount
systemctl start media-acid-web.automount

With the standard Raspberry Pi setup, the cat command is not available as a sudo command while the bash shell is. I’m taking advantage of that by running the bash shell as root and then all of the other commands with root privileges.

Windows File Recovery from Microsoft

Last week Microsoft released a new command line tool in the Microsoft Store. It requires running Windows Version 2004.

Last year when I was importing pictures from a camera memory card, the import program crashed. It only managed to import a few of the pictures, but it deleted all of the pictures from the memory card.

Because of my long history understanding how file systems work, I knew that the pictures were likely still on the card, just not in the directory system I couldn’t find a tool at the time to recover the files. I’d put a label on the card and set it aside. As soon as I heard about this program I installed it and tried it out on the memory card.

The funny thing is that it recovered several thousand images, going back several years. I ran it in signature mode, looking for jpeg files. In doing that, It’s just looking at all the data blocks on the drive, looking for jpeg files.

This time I used Adobe Lightroom CC to import the images and group them by the embedded EXIF data. Looking at the details, the photos that got deleted by mistake were likely from 10/28/2018. All of the photos attributed to 06/29/2020 are missing exifdata, and are just recorded as the date they were recovered.

This is a good reminder that you probably don’t want to throw away old digital media, even when you think you’ve gotten rid of all incriminating data. mspb(‘9n26s50ln705’, function(badge) { document.getElementById(‘mspb-yfhgln7xadp6’).innerHTML = badge; });

Retrieve Wi-Fi Password in Windows 10

Sometimes I go to a place I’ve been before and my computer remembers the WiFi password while my brain does not. The following Windows PowerShell commands will display most of the remembered passwords.

netsh wlan show profiles

netsh wlan show profiles name=’ProfileToDisplay’ key=clear

The first command displays all of the networks your computer has remembered. It can be rather long if you’ve had your computer for several years and done a reasonable amount of traveling and using WiFi in strange locations.

2019-11-27 (1)

The second command takes the profile name that you retrieved with the first command and displays details of the selected profile. The password is displayed as the Key Content section of the Security settings.

2019-11-27 (2)

Microsoft Surface Pro 4 Screen Flicker

My nearly four year old Microsoft Surface Pro 4 recently developed a screen flicker issue. I’m sure it was some driver update that was installed, but I’m not exactly sure when. The observed activity is that a horizontal section at the bottom of the screen about the same size of the mouse cursor flickers with data that is duplicated from the top of the screen. The rest of the screen appears to be bouncing up and down by one scan line, making the text nearly unreadable.

I searched online, and found references to flicker problems with some cases being purely hardware related and requiring replacement by Microsoft. I also found references to the problem only occurring after the screen data had not changed for a few seconds. This static screen problem matched my problem exactly.

I found a workaround by enabling the seconds display in the clock in the task bar. This is done by creating a registry entry. If the following is in a “.reg” file it will set the value to show the seconds on the clock.

Windows Registry Editor Version 5.00


I read that the seconds are not enabled by default because it saves a bit of processing power, which can be important on battery powered devices. For me the difference is minimal and worth not spending more time researching a probable driver issue that may be taken care of automatically in some future windows update.

2019-10-04 (1)2019-10-04

I hope that this helps someone else. The screen flicker/jitter was annoying and I wasn’t able to find the root cause.


My new favorite WiFi Analysis Program

I recently came across WinFi Lite, and while it claims to be in beta and for professionals only, it’s currently my favorite WiFi analysis program.  The fact that it was in the Microsoft store gives me the idea that it will uninstall cleanly if I decide to get rid of it later.


The default view shows details about both 2.4 and 5 GHz networks nearby. The first picture was what it looked like when I ran it in my local Starbucks on my Microsoft Surface 4 Pro.  The next picture was what it looked like when I ran it in my apartment. In my apartment I was connected to my network via wired ethernet, so the Surface WiFi adapter wasn’t being used for my active connection. At Starbucks, I was connected to the WiFi.

2019-09-11 (1)

While I was at Starbucks, the number of networks it could see was 188. That number is visible in the top right of the image. Just to the left of that number are a set of buttons that allow you to look at 2.4GHz, 5GHz, or All available networks.

My apartment showed only 161 networks by comparison, but that number was bouncing around as it rescanned in both locations. I was surprised that the Starbucks had so many visible networks. There are a lot of details available in this tool, and it’s current price makes it an interesting tool to work with. I used to like inSSIDer, but the developers choice to dumb down the free version led me to drift away from it.

iTunes, Microsoft Store, COM Interface Type Library

Several years ago I’d written a program to manipulate data in the iTunes library using the approved Apple COM API. Part of the way this works in a C program is to include a type library in the headers defining all of the function calls. When iTunes is installed in the traditional way, Apple embedded the type library in the executable, and the executable was installed in a traditional location.

#import "C:/Program Files (x86)/iTunes/iTunes.exe"
using namespace iTunesLib;

With the installation of iTunes from the Microsoft store, the iTunes executable no longer lives in that location. Today my application builds properly with the following import command, but it may change mysteriously with version changes and automatic updates via the store.

#import "C:/Program Files/WindowsApps/AppleInc.iTunes_12093.3.37141.0_x64__nzyj5cx40ttqa/iTunes.exe"
using namespace iTunesLib;

My program builds and runs more reliably than it used to, which I’m assuming is in part due to the fact that I appear to now be using a 64 bit version of iTunes, and all the extra work Apple put in to make iTunes more reliable on windows in general.

Finding the iTunes application itself was the hardest part of the transition. I’m happy the API still exists because Apple no longer hosts easy access to the documentation for the API, and seems to be the most complete and searchable information.

iTunes, Microsoft Store, Microsoft Surface

Last year, Apple finally worked enough with Microsoft to get the iTunes program for windows available in the Microsoft Online Store. I’d always had problems with upgrading iTunes in windows in the past, requiring me to completely uninstall, reboot, and install the new version each time I wanted to upgrade. Often I had to not just uninstall iTunes, but search for other helper programs that Apple might have installed and uninstall them before rebooting.  I did the complete uninstall before I installed the version from the Microsoft store. Since that time, iTunes has almost magically been up to date on my desktop computer. The Microsoft store updates seem to get installed in downtime on my computer and everything just works.

I’m stuck in my ways a bit as far as music goes. I’ve get a large ripped CD collection, that I keep the originals all in a set of binders including the original paper inserts. My iPhone has 256GB of storage, more than half of which is my music.

I’ve kept my iPhone synchronized with my desktop computer because of the storage requirements of all of the music in the past, but at times have wished I was synchronizing with my Microsoft Surface Pro 4 tablet that I travel with, and use just as much as my desktop. My Surface has 256GB of storage in the internal SSD, and I’ve been using a 256GB micro sd card in the accessible storage slot for the past couple of years. That’s good for movies while traveling, but I didn’t want to allocate over half the space to iTunes.


The falling price of flash cards recently convinced me to buy a new 512GB flash card to leave in the Surface. I was able to get all of my music transferred over to the SD card and iTunes installed from the Microsoft Store with very little impact on the internal storage on my Surface. I followed the Apple support ducument and had a few issues because my library had never been consolidated from my early MP3 ripping days.

I’ve been running my Surface SSD with between 50 and 70GB free, which from what I’ve read about SSD usage is good for both lifespan and performance. The iTunes directory on my micro SD card consists of 24,169 files and 137,859,861,360 bytes according to a simple dir /s command.

All was looking good until I got around to connecting my iPhone to the new machine and telling it to backup on the new machine. The backup completed correctly, but I then found out that it had used up all the free space on my internal SSD and I was now down to less than 3GB free space.

A quick search on the web led me to this page explaining how to relocate the backups to an external drive in windows. That seemed good, until I realized that the directory described does not exist on my machine. One more change that seems to have happened to iTunes locations in the Microsoft Store move. A search on my machine led me to find the MobileSync directory in my user profile directory. I used robocopy to move the backup directory to an appropriate directory on my flash card, which took a while because it consisted of 58,623 files and 77,743,703,474 bytes. I then created a directory junction from the SSD location to the flash location.

robocopy /COPYALL /E /MOVE C:\Users\Wim\Apple\MobileSync\Backup D:\Wim\Apple\MobileSync\Backup
mklink /J C:\Users\Wim\Apple\MobileSync\Backup D:\Wim\Apple\MobileSync\Backup

After all that had completed I started iTunes and connected my phone, initiating another backup. Everything now appears to be working properly, with iTunes storing both it’s library and device backups on my secondary storage device.

The only drawback I’ve currently run into is that I use Windows Server Essentials 2016 as a home server and it’s device backup feature to backup my machine for emergency file recovery. The microsd card is recognized as removable media, and the backup software doesn’t easily let me include it in the regular backup strategy.

vcpkg, OpenCV, and Visual Studio

Several years ago I was playing around with a Logitech C920 webcam using OpenCV on Linux.

Recently I decided I wanted to get the same basic functionality under windows with minimal effort, so looked into what it would take to get OpenCV running on windows. I was amazed to come across a YouTube video showing the use of vcpkg as a library package manager under windows that allowed downloading, building, and installing many common libraries quite easily.

I was nicely amazed at how it worked..  Issuing just a few commands in powershell I was able to quickly download and build both vcpkg and OpenCV.

cd .\Source\Repos\
git clone
cd .\vcpkg\
.\vcpkg.exe integrate install
.\vcpkg.exe install opencv
.\vcpkg.exe install opencv:x64-windows

The one thing that bothers me the most is that I now have used over 7GB of space on my local drive on my 256GB SSD. That estimate is according to a quick change directory into the vcpkg directory and running the command dir /s /w it returned:

     Total Files Listed:
36549 File(s)  7,296,147,088 bytes
21911 Dir(s)  79,514,853,376 bytes free

My old program from Linux was able to run in my current Windows 10 environment with the only code change required being replacing the unix sleep() command with an appropriate windows command.

Here’s what the entire install process looked like in the shell:


Odd Wildcard Matching in Windows 10

I recently ran into an odd behavior of more files matching a pattern than I expected. I’d used exiftool to modify the dates on files my GoPro produced. It creates backup files of the original images when it modifies the tags. Here’s the command I ran.

exiftool.exe -r "-AllDates+=4:7:6 17:40:00" -ext jpg f:\GoPro\20170807

Now I had about 4000 files with the .JPG extension and another 4000 files with a .JPG_original extension.

I ran my program that parses the directory structure and turns all those images into a time lapse movie, and it seemed to be including both the file extensions, making a very disjointed movie.

I loaded my source code in the debugger and it seemed to be doing a findfirst / findnext specifically looking for .JPG files, and not some other extension, but it was definitely retrieving files both with .JPG and .JPG_original extensions.

I then ran a couple of commands at the windows command prompt and was surprised to find the same results there.

dir F:\GoPro\20170807\372GOPRO\G*.JPG /p
dir F:\GoPro\20170807\372GOPRO\G???????.JPG /p

Each command returned both the JPG and JPG_original files.

dir F:\GoPro\20170807\372GOPRO\G*.JPG_original /p

returned just the JPG_original files.

dir F:\GoPro\20170807\372GOPRO\G??????.JPG /p

had one less question mark and correctly returned no files.

This is all unexpected behavior, though I’m glad to see that it was consistent with the operating system and not something specific to the C runtime. I’d love an explanation of what’s going on.

85% Processor Usage while idle

My Microsoft Surface Pro 4 has recently started showing high CPU usage even while I’ve got nothing running in the foreground.

It’s annoying because I’m used to the idea of lower CPU usage being related to extended battery life, and if the CPU is being used by an unnecessary program, I’ll stop using that program.

2016-05-15 (1)

The other interesting thing is that Microsoft Edge is showing as a significant user of both CPU and Memory. I’ve not yet launched Microsoft Edge since I told the operating system to restart.

Is this some placeholder in the Task Manager?

If I run the Sysinternals Process Explorer side by side, it shows the machine being very lightly used, which is closer to what I expect to see from task manager. If I want real information on what’s going on with my computer I’m more likely to use the Sysinternals tool, but the task manager is already installed on all windows machines, and has some simple graphs to look at, including watching network traffic.

2016-05-15 (2)