File History Command Line Tool

There’s a command called fhmanagew.exe that comes with Windows 10 (not sure about Windows 8.1, but I assume so).  The full path is c:\windows\system32\fhmanagew.exe. This tool is used for managing certain aspects of File History, and contains a few undocumented features.

From what I can tell,  Microsoft has only mentioned the -cleanup argument which is used like: fhmanagew.exe -cleanup <# days> [-quiet]

A couple examples:
fhmanagew.exe -cleanup 365
fhmanagew.exe -cleanup 30 -quiet

I used strings.exe by sysinternals (a Windows port of a handy *nix tool for extracting raw strings from a binary file) to analyze fhmanagew.exe and found the following arguments are available: Continue reading “File History Command Line Tool”

DIY Raspberry Pi Zero “Clapper”

“Clap on! Clap off! The Clapper!”

This project will walk you through the creation of a DIY “Clapper”.  It uses the Adafruit MAX4466 Microphone Amp to detect when the claps occur, then sends an RF signal to RF-controlled power plugs.

Continue reading “DIY Raspberry Pi Zero “Clapper””

Kinect support for Raspberry Pi using libfreenect

Developing apps for the Raspberry Pi that utilize the Xbox 360 Kinect is best accomplished with libfreenect. Libfreenect is an open-source library that provides access to the sensors and motors on the Kinect.

Raspbian’s apt repository has version 0.2 of libfreenect, which is quite old and seems to be missing a lot of the features that the latest code has. I’ve documented the steps for building the latest LibFreenect source code and dependencies, below (0.5.3 as of this post).

Continue reading “Kinect support for Raspberry Pi using libfreenect”

Office 2016 and licensing error 0x8004FC12

Several people on the TechNet forums (and other interwebz sites) have encountered error 0x8004FC12 with Office 2013, 2016 and even Windows. It seems most of these cases have gone unresolved or only gotten fixed by refreshing or reinstalling Windows. I recently found myself in the same boat. When I would try to activate Office 2016, I received the error:

“We’re sorry, something went wrong and we can’t do this for you right now. Please try again later. (0x8004FC12)”

The application event log had:

“Acquisition of End User License failed. hr=0x8004C12”.

Continue reading “Office 2016 and licensing error 0x8004FC12”

Waiting (or “sleeping”) in a batch file

Commands like timeout.exe were added to Windows to make waiting in a batch file easier. Unfortunately timeout.exe still leaves much to be desired. There are several alternatives people use to simulate a delay in the Windows Command Prompt (cmd.exe).

Below you can see an analysis of the suggestions from this StackOverflow post, along with one additional suggestion I have that will increase precision (method 1 below).

The key factors I’m analyzing is the time precision of a command and I attempt to determine the compatibility with past versions of Windows. I also want this to work out-of-the-box with Windows and not require an external executable to be loaded.

My test consisted of the following methods:

  • Method 1: Custom Function
    Command: call :waitfor 5000>nul (see below for implementation details)
  • Method 2: Ping.exe (dummy IP, timeout)
    Command: ping.exe -n 1 -w 5000 1.1.1.1 >nul 2>&1
  • Method 3: Ping.exe (localhost, 1 sec between pings)
    Command: ping.exe -n 6 -w 1 127.0.0.1 >nul 2>&1
  • Method 4: Powershell.exe
    Command: powershell.exe -command "Start-Sleep -Milliseconds 5000">nul
  • Method 5: Timeout.exe
    Command: timeout.exe /t 5 /nobreak >nul 2>&1
  • Method 6: VBScript (cscript.exe)
    Command: echo WScript.Sleep^(WScript.Arguments^(0^)^) >"%temp%sleep.vbs" && cscript "%temp%sleep.vbs" 5000 >nul

Continue reading “Waiting (or “sleeping”) in a batch file”

Debugging Windows Service Projects (C#)

Many developers find it annoying to debug the built-in Windows Service projects in Visual Studio. You can’t simply create a new project and click the “Run” button in Visual Studio and expect it to run with a debugger attached, like you can with most other project types. Normally you would install the service, start it, and attach a debugger to the process, but this is a hassle and doesn’t help much if you need to debug issues in the OnStart method.

To solve this problem and help with diagnostics, I typically add some boilerplate logic to my Windows Service projects. By passing in command line args to my service .exe, I can either have it launch in a light-weight debug console or make it wait to call the OnStart method until a debugger is attached.

Continue reading “Debugging Windows Service Projects (C#)”

Launching RDP from KeePass 2.x with auto-login

Configuring KeePass to launch RDP:

If you manage all of your RDP connections through KeePass, you may notice there’s no direct or easy way of launching Remote Desktop Client and automatically logging into a remote machine.

The following few steps will help guide you through configuring KeePass to automatically launch an RDP connection through a menu item or accelerator key on that entry in KeePass.

Continue reading “Launching RDP from KeePass 2.x with auto-login”