Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Batch parse user input
Name: aegis Date: August 7, 2008 at 14:44:41 Pacific OS: XP Home SP2 CPU/Ram: AMD 3.8/2gb Product: Generic
Comment:
i've searched but I can't find out how to parse/extract a couple of characters from a users input. I need the first two right now, but it would be handy to learn how to get any section. I'd really appreciate any help/suggestions. Is there a 'good' XP Batch tutor somewhere? The ones I've found don't give enough examples.
save the above as test.vbs and on command line(batch), usage:
C:\test>cscript /nologo test.vbs "userinput" 2 4 seri
0
Response Number 2
Name: aegis Date: August 7, 2008 at 19:21:34 Pacific
Reply:
Thanks for responding Ghostdog, but I'm afraid I don't understand. I can't use a script, I have to do this with a batch file.
I'm using the following:
set /p q=Enter the name:
and I get q equal to the name that is typed in, but I need to extract the first two characters in q and set another variable to those two characters. I'm sorry if I'm not making things clear.
0
Response Number 3
Name: ghostdog Date: August 8, 2008 at 00:27:09 Pacific
Reply:
like i said, check out the set /? help. There's a portion that shows you how to do substring.
0
Response Number 4
Name: aegis Date: August 8, 2008 at 08:47:19 Pacific
Reply:
Sorry about that Ghostdog! I messed up when I did the set /?. I didn't hit a key and only saw the first few lines. I found the 'subset' instructions and will see if my feeble old brain can figure it out and get it to work. Thanks very much!
0
Response Number 5
Name: aegis Date: August 8, 2008 at 13:03:07 Pacific
Reply:
OK, I'm pretty slow and it took me quite a while, but after much trial and error I finally got it right. I did it with: set q=%r:0,2%
Summary: I am new at this so forgive my ugly batch script (it's just plain old windows batch scripting language) . I am trying to normalize user input so that directory path entered by user would end up withou...
Summary: I don't know if you can do it directly using just cmd.exe's internal commands. For example, the SET /P command echoes the password back. Does anyone know of a way? In the meantime, here's a technique ...
Summary: I wanted to do this a while back but I dont think there is any way. With XP they cut out the user input commands with cmd. I used this site to get all my batch stuff http://www.ss64.com/nt/ (it is XP)...