Windows command-line installers used by some programs: problems showing syntax and parameters

As time goes by, it is (fortunately) more usual to find command-line installers for most Windows GUI programs, so you can make batch and offline console installations.

But sometimes I have found a strange behavior with several installers when requesting (via -?, -help... etc) their usage syntax: they open a new console (cmd) windows, show (quickly) syntax and parameters... and close again to fast, so the user doesn't have time to read anything.

Example: The Bitvise SSH Installer (trial version available). I request syntax as its docs says :

BvSshServer-Inst.exe -?

A new cmd console opens saying things like:

This program will install Bitvise SSH Server 6.07
on the machine it is being run on.
... blah blah blah 

... and the window closes again. I don't have time to read anymore.
I have seen this strange behavior on Windows 7, but not on Windows XP (tested on three machines).

Why is this happening?
How could it be solved/workarounded?

NOTE:
- When accessing to my machine via remote console (tested with SSH remote console) things go OK (I presume telnet would get it working too, but I have not tested it):

d:\Installer\>BvSshServer-Inst.exe -? | more
This program will install Bitvise SSH Server 6.07
on the machine it is being run on.

Bitvise SSH Server is an SSH2 server for Windows 2000 or newer, including
the latest Windows 8.1 and 2012 R2. Please see www.bitvise.com/ssh-server
for more information.

This program must be run by a user with administrator privileges. If run
without command line options, installation will be performed in interactive
mode. If run with command line options without the '-interactive' option,
installation will be performed in unattended mode.

Usage:
 BvSshServer-Inst -installDir=directory OR -defaultSite OR -site=site-name
                  [-force OR -abortOnWarning[=warning-list-or-mask]
                  [-acceptEULA] [-interactive] [-noRollback]
                  [-activationCode=activation-code-hex]
                  [-keypairs=keypairs-file]
                  [-settings=settings-file]
                  [-siteTypeSettings=fileName]
                  [-startService]
                  [-startBssCtrl]

NOTE2:
- These commands do not solve the issue neither:

start "BvSshServer-Inst.exe -? | more"
cmd /k "BvSshServer-Inst.exe -? | more"
BvSshServer-Inst.exe -? | more > Syntax.txt
BvSshServer-Inst.exe -? > Syntax.txt
BvSshServer-Inst.exe -? | more 2> Syntax.txt

Why is this happening?

You didn't provide other examples besides Bitvise, but it seems to be a UAC prompt issue. If the program doesn't run with the elevated privileges it requires, and thus is required to display a UAC prompt, output is written to a different (new?) STDOUT. Thus the second cmd window AND why standard text redirection to an output file (>) doesn't seem to work. This Stack Overflow question seems to confirm this.

As to why it works on XP, it doesn't have UAC. Likewise, you can get the same behavior on the command line in Windows 7 with an elevated command prompt:

  • Run -> cmd.exe -> Ctrl + Shift + Enter

  • Navigate to wherever the Bitvise installer is located and run it with the -help option; output will be normal.

How could it be solved/workarounded?

As to a solution to running such programs from the command line without STDOUT redirection by the UAC prompt for that program, the final comments in the question above provide a clue that you can use the Elevation PowerToys to accomplish this.

  • Download the file from here (linked at the top of the Elevation PowerToys page). This is actually an archive, double-click to extract the files where you like (I suggest a folder!).

  • Once the files are extracted, copy elevate.cmd and elevate.vbs and place them somewhere useful (in the same directory).

  • Create a batch file, making sure to take into account appropriate paths to elevate.cmd. This will still display a UAC prompt, but not for Bitvise, and this makes all the difference.

     @echo off
     setlocal enabledelayedexpansion
    
     set CmdDir=%~dp0
     set CmdDir=%CmdDir:~0,-1%
    
     :: Check for Mandatory Label\High Mandatory Level
     whoami /groups | find "S-1-16-12288" > nul
     if "%errorlevel%"=="0" (
     echo Running as elevated user.  Continuing script.
     ) else (
     echo Not running as elevated user.
     echo Relaunching Elevated: "%~dpnx0" %*
    
     if exist "%CmdDir%\elevate.cmd" (
         set ELEVATE_COMMAND="%CmdDir%\elevate.cmd"
     ) else (
         set ELEVATE_COMMAND=elevate.cmd
     )
    
     set CARET=^^
     !ELEVATE_COMMAND! cmd /k cd /d "%~dp0" !CARET!^& call "%~dpnx0" %*
     goto :EOF
     )
    
     :: Continue script here
     BvSshClient-Inst.exe -help 
     BvSshClient-Inst.exe -help > txt.txt
    
     echo Arguments passed: %*
    

Basic instructions on installing some of these toys is here.