Saved Bookmarks
| 1. |
Solve : disallow wildcards with the 'set' command? |
|
Answer» I HOPE one of you BRAINY folk can help. I've written a rather lengthy batch file and all works brilliantly, however as it involves deleting and renaming server based profiles based on user input I can't risk it allowing them to input wildcards otherwise they could technically have the ability to cause quite a bit of damage. So, basically all I need is a way of trapping user input of wildcards (eg * and ?) via a 'set /p' command... any ideas? Is there a way of saying:
Code: [SELECT]@echo off set /p var=Enter Data: echo %var% | find "*" if not errorlevel 1 echo Wildcard present The operative instruction is checking the errorlevel for zero (not 1) indicating there is a wildcard in the user input. By trapping the data this way you can bring your batch file in for a gentle landing rather than SLAMMING into the mountain. Good luck. Thanks for the replies and PM's chaps/chapettes. Sidewinders solution is the one I've used for it's SIMPLICITY. So simple yet works a treat (I think I was trying to overcomplicate things ) Thanks again! |
|