setx loses quotes

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
taripo
Posts: 228
Joined: 01 Aug 2011 13:48

Re: setx loses quotes

#16 Post by taripo » 13 Aug 2011 17:48

Ed Dyreen wrote:'
I've studied the BennyLevel, I never ran the code but it seems he determines the character of a variable using the the fact that choice will accept only the first choice.

Code: Select all

@Echo. Fully specified file name.| CHOICE /n /c:abcdefgh.> NUL
  For %%D in (A B C D E F G H ) do if errorlevel H%%D set D=%%D
  Echo. The drive letter in your Fully specified file name: %D%
If it does what I think it does, this trick has become abundant. :o


I see it mentioned here
http://groups.google.com/group/alt.msdo ... derson+dos

@echo off
choice/n/c abcdefghijklmnopqrstuvwxyz Choose:
if not errorlevel 17 goto end
for %%b in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if errorlevel %%b set drive=%%b
vol %drive%: | find "%drive% "
:end
set drive=

I get the idea..

Looks like in NT you can't test errorlevel against a letter. So his method doesn't apply to NT..

How do you think it is superfluous though?


I'd think it looks rather superfluous because with SET /P drive=
and then you test the value of drive without using errorlevel

If you just used CHOICE(in NT's case, choice.exe) and you didn't use SET /P then I guess it'd be a problem, 'cos I can't see how it can be done in NT otherwise?

Post Reply