2014-06-29 00:00:15 +02:00
|
|
|
@echo off
|
|
|
|
setlocal
|
2014-07-12 00:37:25 +02:00
|
|
|
if "%1"=="noechoback" (
|
2015-02-11 20:44:05 +01:00
|
|
|
call :exprog
|
2014-07-12 00:37:25 +02:00
|
|
|
) else (
|
2015-03-01 07:06:53 +01:00
|
|
|
set /p INPUT=<CON >CON
|
2014-07-12 00:37:25 +02:00
|
|
|
)
|
2015-03-01 07:06:53 +01:00
|
|
|
set /p ="'%INPUT%'"<NUL
|
2014-06-29 00:00:15 +02:00
|
|
|
endlocal
|
|
|
|
exit /b 0
|
2015-02-11 20:44:05 +01:00
|
|
|
|
|
|
|
:exprog
|
|
|
|
|
|
|
|
:: where /q powershell
|
|
|
|
:: Win <Vista and <Server2008 don't have `WHERE`.
|
|
|
|
powershell /? >NUL 2>&1
|
|
|
|
|
|
|
|
:: Win <7 and <Server2008R2 don't have PowerShell as default.
|
|
|
|
:: Win XP and Server2003 have `ScriptPW` (`scriptpw.dll`).
|
|
|
|
:: In the systems that don't have both, an error is thrown.
|
|
|
|
if errorlevel 1 (
|
|
|
|
set "EXCOMMAND=cscript //nologo "%~dp0read.cs.js""
|
|
|
|
) else (
|
|
|
|
set "EXCOMMAND=powershell -Command "$text = read-host -AsSecureString; ^
|
|
|
|
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR^($text^); ^
|
|
|
|
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto^($BSTR^)""
|
|
|
|
)
|
|
|
|
:: echo %EXCOMMAND%
|
2015-03-01 07:06:53 +01:00
|
|
|
for /f "usebackq delims=" %%i in (`%EXCOMMAND%`) do set "INPUT=%%i"
|
2015-02-11 20:44:05 +01:00
|
|
|
exit /b
|