troubleshooting Question

Batch file function to search string that is entered by user, for invalid characters...

Avatar of Ryan Bennett
Ryan BennettFlag for United States of America asked on
Microsoft DOSWindows XPWindows Batch
8 Comments1 Solution1704 ViewsLast Modified:
I have limited skills when it comes to bat files, and am not experienced with using loops,
 which I think that is what is needed in this case.

 I am writing a bat file that will take an input string from the user and then act on the string.
 But I need to check that string aginst a list of invalid characters, including spaces which I don't
 exactly know how to add to the list of characters.

ie..
 set invalidlist="`~!@#$^&*()=+[]{}\|;:'",<>/?"
 set invalidchar=" "
 set string=

:start
 set /p string= enter your string
 for loop here check for invalid chars (?)
 if invalid chars are found goto badchar
 
 if not bad chars are found, goto work
 
 :badchar
 echo.
 echo you cannot use spaces of any of the following characters
 echo `~!@#$^&*()=+[]{}\|;:'",<>/?    <---<< also ow can you echo these and get them to show up as output?
 goto start
 
and so on......

   Does this make sense? I guess basically, the user enters a string and presses enter, the function would look at each character
  and compare it with each invalid character and if there is a match there it will error out and make them re-enter a string again.
  if there are no errors found it will continue on.
 
   Thanks,
   RBennett
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros