| 1. |
Solve : string inside a sting? |
|
Answer» So I need to loop a 'choice /c ...' %B% amount of times, setting a new veriable each time it loops named p%b%. I got the pulling thing, but %p%b%% doesnt work, and neither does %%p%b%%%. I believe you have to do this with a for loop, but when I typed for /?, I had no clue what they were talking about. If anyone could walk me through one of these that would be GREAT! A workaround would be great too code below. Could not test your code beyond the ploop. Need more info about the exs files and their contents. Not sure why you want/need a choice statement in a for loop. Perhaps if you told us what you're trying to accomplish, we might better find a solution.I am attempting to create a password that does not show up on the screen, thus it would CLEAR out all input as soon as you enter it, that was why I was using choice /c. The p#.exs are just renamed text files that corrospond with the errorlevel of choice /c for the correct password. Would you mind expanding on the 'call a set' thing you were talking about? I have never heard of it before. Quote from: Squashman on June 11, 2012, 10:02:30 AM I think what you are trying to do is access an array variable. In which case you would need to use delayed expansion. Not sure what this is, but will look into it when I get home.Quote from: Lemonilla on June 11, 2012, 10:08:48 AM I am attempting to create a password that does not show up on the screen, thus it would clear out all input as soon as you enter it, that was why I was using choice /c. Check out this post for information on passwords and batch processing. The posted code will not run on a 64 bit OS. Have you considered VBScript or Powershell? More verbose to be sure but you'll have more secure results. Control-Break can circumvent any 'protections' made by way of a batch file....Quote from: BC_Programmer on June 11, 2012, 12:36:23 PM Control-Break can circumvent any 'protections' made by way of a batch file....Quote from: Sidewinder on June 11, 2012, 12:23:33 PM Check out this post for information on passwords and batch processing.Sorry to be the pessimist, but I believe you guys are TOTALLY missing the point of the program. It isn't for the sake of security, I could really just ASK him not to use my computer and problem solved. It's more for the practice programming and for learning new commands. Anyway, problem was fixed with a reorganization of code. Code: [Select]@echo off if exist stop.txt del /f stop.txt title extraSecurity set /p p#=<p.exs set b=0 :cloop title Letter Number:%b% set /a b+=1 choice /c 1234567890qwertyuiopasdfghjklzxcvbnmABCDEFGHIJKLMNOPQRSTUVWXYZ /n /cs /m "Password?" cls set /p p=<p%b%.exs IF %errorlevel% NEQ %p% goto exit if %b% EQU %p#% goto end goto cloop :end echo OK >>stop.txt if not exist stop.txt goto end exit :exit if exist stop.txt shutdown -s -f -t 1 if exist stop.txt exit goto exit |
|