Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for usrin.kix

(view source code of usrin.kix as plain text)

  1. @ECHO OFF
  2. :: UsrInKix.bat,  Version 1.00 for Win32
  3. :: Batch file using Kix to retreive user input
  4. :: Written by Rob van der Woude
  5. :: http://www.robvanderwoude.com
  6.  
  7. :: Create a temporary Kix script that will
  8. :: in turn create a temporary batch file:
  9. > %TEMP%.\UserIn.kix ECHO REDIRECTOUTPUT( "NUL" )
  10. >>%TEMP%.\UserIn.kix ECHO GETS $UserIn
  11. >>%TEMP%.\UserIn.kix ECHO IF OPEN( 1, "@SCRIPTDIR\UserIn.bat", 5 ) = 0
  12. >>%TEMP%.\UserIn.kix ECHO     WRITELINE( 1, "SET UserIn=" + $UserIn )
  13. >>%TEMP%.\UserIn.kix ECHO ELSE
  14. >>%TEMP%.\UserIn.kix ECHO     ? "Error opening temporary file, errorcode = " + @ERROR
  15. >>%TEMP%.\UserIn.kix ECHO ENDIF
  16. :: Prompt for user input:
  17. ECHO Type anything you like and press Enter when finished:
  18. :: Retreive user input using the Kix script, and
  19. :: then store the result in a temporary batch file:
  20. KIX32.EXE %TEMP%.\UserIn.kix
  21. :: Call the temporary batch file to store
  22. :: the result in an environment variable:
  23. CALL %TEMP%.\UserIn.bat
  24. :: Clean up the temporary files:
  25. IF EXIST %TEMP%.\UserIn.* DEL %TEMP%.\UserIn.*
  26. :: Finaly, display the result:
  27. ECHO You typed: %UserIn%
  28.  

page last uploaded: 2017-08-21, 14:26