Advertisement
Fawers

VBS Input

Oct 29th, 2012
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.11 KB | None | 0 0
  1. ::VBSINPUT.CMD was written by Fawers
  2. ::==================================
  3. ::Syntax:
  4. ::vbsinput varName [text] [windowTitle] [defaultInput]
  5. ::                       --varName      Variable name
  6. ::                       --text         Brief description or question
  7. ::                       --windowTitle  Window Title
  8. ::                       --defaultInput Default option
  9. ::Parameters in [brackets] are optional.
  10. ::
  11. ::Inspired by Rob van der Woude's code to capture VBScript output on DOS
  12. ::http://www.robvanderwoude.com/usermessages.php
  13.  
  14. @echo off
  15. if "%~1" == "" (
  16.   setlocal enableDelayedExpansion
  17.   echo,
  18.   for /f "skip=2 delims=" %%t in ('type "%~f0"^|find "::"^|find /v "for /f"'
  19. ) do (set line=%%t
  20.     echo,!line:~2!
  21.   )
  22.   endlocal
  23.   exit /b 1
  24. )
  25. pushd %temp%
  26. set vbs="%~n0.vbs"
  27. for /f "tokens=2 delims=:" %%c in ('chcp') do set /a "code=%%c"
  28. if not [%code%] == [1252] chcp 1252 >nul 2>&1
  29. >%vbs% echo wscript.echo inputbox("%~2", "%~3", "%~4"^)
  30. chcp %code% >nul 2>&1
  31. set code=
  32. for /f "delims=" %%v in ('cscript //nologo %vbs%') do ^
  33. if not "%%~v" == "" set "%~1=%%v"
  34. del %vbs%
  35. set vbs=
  36. popd
  37. exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement