Making it work under Windows NT and Windows 2000STRINGS and ASET (and most other environment manipulation utilities) do not work under Windows NT and Windows 2000, even though they work as advertised in a DOS session or a DOS window under Microsoft Windows 9x. Why is this, and can it be corrected?Last question first: No, the problem cannot be corrected. Though Windows 2000 may complain "not enough environment space" when running STRINGS or ASET, the problem is not due to insufficient environment space. The problem is caused by the fact that STRINGS and ASET both use the DOS interrupt call INT 21 to alter environment variables. Windows NT and Windows 2000 are incompatible with this common technique. Here are some alternate solutions:Windows 2000: Get input from keyboardTo prompt the user for a value and then put their keyboard reply into an environment variable, run this command:
SET /P VARNAME=Please enter your name:
SET will display the prompt "Please enter your name:" to the user, who is expected to type a string of lettes and press ENTER. Whatever they type will be stored in the variable %VARNAME, where it can be retrieved for later operations.Windows NT: Get input from keyboardThis technique doesn't work with Windows NT. However, Simon Sheppard (www.ss64.com) wrote this script using Windows Scripting Host (present on NT and Win2K machines) to store user input into an environment variable:CODE: [Copy to clipboard]
:: Input1.cmd - A routine to prompt the user for an input string.
:: Requires WSH version 1.0 or later.
:: Input string is stored in the variable v_input
:: Use optional command line argument UCASE to convert input to all uppercase.
:: usage:
:: input1
:: input1 ucase
@ECHO off
SETLOCAL
SET v_vbs=%TEMP%\~tmp.VBS
SET v_cmd=%TEMP%\~tmp.cmd
ECHO Set oFS=CreateObject("Scripting.FileSystemObject")>%v_vbs%
ECHO oFS.OpenTextFile("CON",2).Write "Enter a string: ">>%v_vbs%
ECHO S=%1(Trim(oFS.OpenTextFile("CON",1).Readline))>>%v_vbs%
ECHO oFS.CreateTextFile("%v_cmd%",2).Write "set v_input=">>%v_vbs%
ECHO oFS.OpenTextFile("%v_cmd%",8).Write S>>%v_vbs%
cscript.exe //nologo %v_vbs%
CALL %v_cmd%
DEL %v_vbs%
DEL %v_cmd%
SET v_input
ENDLOCAL & SET v_input=%v_input% One workaround is to place the command(s) to these utilities in the file called C:\WINNT\AUTOEXEC.NT or C:\%WINDIR%\AUTOEXEC.NT. The file AUTOEXEC.NT is a "batch" file and it runs like AUTOEXEC.BAT does in normal MS-DOS. If you are able, execute ASET or STRINGS from within AUTOEXEC.NT. Every time CMD.EXE or COMMAND.COM is executed, AUTOEXEC.NT will be executed, and any variables which are set there will persist for the life of the CMD or COMMAND window.There's probably another workaround, but I don't know what it is right now. If someone else does, please e-mail me. Thanks! |
|