BAT File Query

Microsoft Windows nt server 4.0
January 14, 2010 at 03:04:01
Specs: Windows NT

A couple of questions if I may.

Firstly, I can't for the life of me work out why the SET /P command is not working on my installations of NT4. Googling the command and O/S shows people able to use the /P string to read in and use the input from the user as a variable.

Set /? on my NT machine returns:

Displays, sets, or removes cmd.exe environment variables.

SET [variable=[string]]

variable Specifies the environment-variable name.
string Specifies a series of characters to assign to the variable.

Type SET without parameters to display the current environment variables.

If Command Extensions are enabled SET changes as follows:

SET command invoked with just a variable name, no equal sign or value
will display the value of all variables whose prefix matches the name
given to the SET command. For example:


would display all variables that begin with the letter 'P'

SET command will set the ERRORLEVEL to 1 if the variable name is not
found in the current environment.

SET command will allow an equal sign (=) in the value of an environment
variable in any position other than the first character.

A new switch is added to the SET command:

SET /A expression

The /A switch specifies that the string to the right of the equal sign
is a numerical expression that is evaluated. The expression evaluator
is pretty simple and supports the following operations, in decreasing
order of precedence:

() - grouping
* / % - arithmetic operators
+ - - arithmetic operators
<< >> - logical shift
& - bitwise and
^ - bitwise exclusive or
| - bitwise or
= *= /= %= += -= - assignment
&= ^= |= <<= >>=
, - expression separator

If you use any of the logical or modulus operators, you will need to
enclose the expression string in quotes. Any non-numeric strings in the
expression are treated as environment variable names whose values are
converted to numbers before using them. If an environment variable name
is specified but is not defined in the current environment, then a value
of zero is used. This allows you to do arithmetic with environment
variable values without having to type all those % signs to get their
values. If SET /A is executed from the command line outside of a
command script, then it displays the final value of the expression. The
assignment operator requires an environment variable name to the left of
the assignment operator. Numeric values are decimal numbers, unless
prefixed by 0x for hexidecimal numbers, 0b for binary numbers and 0 for
octals numbers. So 0x12 is the same as 0b10010 is the same as 022.
Please note that the octal notation can be confusing: 08 and 09 are
not valid numbers because 8 and 9 are not valid octal digits.

Environment variable substitution has been enhanced as follows:


would expand the PATH environment variable, substituting each occurrence
of "str1" in the expanded result with "str2". "str2" can be the empty
string to effectively delete all occurrences of "str1" from the expanded
output. "str1" can begin with an asterisk, in which case it will match
everything from the begining of the expanded output to the first
occurrence of the remaining portion of str1.


would expand the PATH environment variable, and then use only the 5
characters that begin at the 11th (offset 10) character of the expanded

Which doesn't mention the /P switch at all.

My other problem is I found a free application to convert my batch file from a .BAT to a .EXE and it works in Windows XP, but the converted .EXE will not work in NT4. Does anyone else know of a good product that converts .BAT to .EXE for free?

Thanks in advance

See More: BAT File Query

Report •

January 14, 2010 at 03:28:37
Not a great choice of a subject. If you use something like 'set /p in NT4' you might get the attention of one of the few helpers who is up to speed on NT4.

Helping others achieve escape felicity


Report •

January 14, 2010 at 03:32:48
No set /p in nt :(

Look here for input in nt. It's sketchy at best.

Personally the "label" version looks better to me(test ok on xp).

Batch Variable how to

Report •

January 14, 2010 at 07:10:39
can NT batch assign errorlevel? like:
set xx=%errorlevel%

i know winME on down won't let you do that but XP will...
a small key-in routine can return an errorlevel equal to the
asc value of key pressed, but it's useless unless the errorlevel can be captured to a var.

key in is:
mov ah,7
int 21
mov ah,4c
int 21

(B4 07 CD 21 B4 4C CD 21)

Report •

Related Solutions

January 14, 2010 at 17:56:52
You raise an interesting poit aboutb set v=%ERRORLEVEL%.

I'll boot in DOS and try it.

I like that key-in thingy.

Helping others achieve escape felicity


Report •

January 16, 2010 at 04:12:11
> Which doesn't mention the /P switch at all.

Only since Windows 2000, and XP for the client versions ... correct me if wrong.

Report •

Ask Question