Skip to content

Instantly share code, notes, and snippets.

@Archigos
Created July 29, 2014 15:25
Show Gist options
  • Save Archigos/6aac75d26f7bae71013f to your computer and use it in GitHub Desktop.
Save Archigos/6aac75d26f7bae71013f to your computer and use it in GitHub Desktop.
Check if NirCmd.exe installed on system, asks to download if missing
@ECHO OFF && SETLOCAL ENABLEEXTENSIONS && SETLOCAL ENABLEDELAYEDEXPANSION
TITLE %COMSPEC% && MODE CON COLS=200 LINES=68 && COLOR 07
PUSHD . && CLS
TITLE NirCmd Test
IF "%~1" == "/?" GOTO Help
IF "%~1" == "" GOTO Beginning
:: This begins comment block
This file checks if NirCmd.exe is available on the system and prompts you to
download if it can not be found.
:: This ends comment block
:Beginning
SET NirCmdAvailable=
SET NirCmdDownload=
nircmd speak text "" >NUL 2>&1
IF ERRORLEVEL 1 (
SET NirCmdAvailable=No
ECHO.
ECHO Some of my batch files rely on NirCmd being installed,
SET /P NirCmdDownload="Do you want to download it now? "
) ELSE (
IF DEFINED NirInstalled (
say "It appears NirCmd is both found and accessible, Congrats"
GOTO EOF
) ELSE (
SETX /M NirInstalled True
nircmd speak text "You must restart the command prompt before the scripts will recognize NirCmd"
GOTO EOF
)
)
IF /I "%NirCmdDownload%"=="Y" GOTO ConfirmYes
IF /I "%NirCmdDownload%"=="N" GOTO ConfirmNo
GOTO :ConfirmUnknown
:ConfirmYes
START "NirCmd" "http://www.nirsoft.net/utils/nircmd.html"
CLS
ECHO.
ECHO Please copy/move NirCmd.exe to your default Windows directory (or just run it and click the internal button that copies it for you)
ECHO Afterwards, run this check again.
GOTO EOF
:ConfirmNo
CLS
ECHO.
ECHO I'm sorry you decided not to download this freeware app that is required for some of my scripts
ECHO You'll be missing out on some features, but I'll try to allow as much as possible to work without it.
ECHO.
ECHO If you reconsider, please run this check again and pick [Y]es instead of [N]o
GOTO EOF
:ConfirmUnknown
CLS
ECHO.
ECHO Um, you are supposed to only select Y for Yes or N for No, please try again...
GOTO Beginning
:Help
ECHO.
ECHO This file checks if NirCmd.exe is available on the system and prompts you to download if it can not be found.
ECHO File can be found here: http://www.nirsoft.net/utils/nircmd.html
GOTO EOF
:FileFound
:EOF
TITLE %COMSPEC%
POPD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment