vshadow.exe can’t be run under WOW64

I use the Microsoft-provided vshadow.exe tool to script some backups, but I got an error when trying to run it on a Windows 7 x64 machine:

ERROR: COM call "m_pVssObject->InitializeForBackup()" failed.
- Returned HRESULT = 0x80042302
- Error text:
- Please re-run VSHADOW.EXE with the /tracing option to get more details

That error is obviously unexplanatory, but some investigation led me to deduce that you can’t run the 32-bit version of the tool on a 64-bit version of Windows. The fix is to download the Windows 7 SDK, install the “Developer tools” portion, and dig the 64-bit version of the tool out from %ProgramFiles%\Microsoft SDKs\Windows\v7.0\Bin\x64\vsstools\vshadow.exe.

If you were Googling that error code, I just saved you some time. You’re welcome.

Run a Windows (“DOS”) batch/cmd script minimized

Here’s a snippet of code I wrote that will force a Windows batch script to run in a minimized window. Insert it at the beginning of the script:

if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized
rem Anything after here will run in a minimized window

It works by having the script re-launch itself in a new minimized window. There are a few juicy batch scripting tricks in here that I recently picked up, like the %~dpnx0 syntax and the special :EOF label. And the overall flag/callback syntax is generally useful for creating self-contained batch scripts.

Other start switches besides /min can provide different parameters for the child window, such as adjusting the CPU priority of the resulting process.