1.

Solve : cd key bat file not working?

Answer» <html><body><p>I'm making a bat file that needs a <a href="https://interviewquestions.tuteehub.com/tag/cd-236847" style="font-weight:bold;" target="_blank" title="Click to know more about CD">CD</a> key to start installation of a program that I made  but it doesn't accept the key I made with the code and with any key it gives this error "missing operator". The code for the bat file is<br/> Code: <a>[Select]</a>echo off<br/>rem xxxxx-xx-xxx-x<br/>rem xxxxx-xx-xxx-3<br/>rem xxxxx-xx-112-3<br/>rem xxxxx-22-112-3<br/>rem 03256-22-112-3<br/>rem 03256/22-112/3=12<br/>cls<br/>echo.<br/>echo.<br/>echo.<br/>echo welcome %USERNAME% to random <a href="https://interviewquestions.tuteehub.com/tag/desktop-949558" style="font-weight:bold;" target="_blank" title="Click to know more about DESKTOP">DESKTOP</a> wallpaper installer by Matthew fosdick<br/>pause<br/>cls<br/>echo.<br/>echo.<br/>echo.<br/>echo you will need 9 photos, you CD key, this CD, and aprox. 12.3 MB Hard disk space.<br/>pause<br/>cls<br/>:CD<br/>echo.<br/>echo.<br/>echo.<br/>echo please enter the first 6 digits of your CD key. EX. 123456-xx-xxx-x<br/>set /<a href="https://interviewquestions.tuteehub.com/tag/p-236832" style="font-weight:bold;" target="_blank" title="Click to know more about P">P</a> key1=key:<br/>cls<br/>echo Thank you. please enter the next 2 digits of your CD key. EX. xxxxxx-78-xxx-x<br/>set /p key2=key:<br/>cls<br/>echo Thank you. please enter the next 3 digits of your CD key. EX. xxxxxx-xx-901-x<br/>set /p key3=key:<br/>cls<br/>echo Thank you. please enter the last digits of your CD key. EX. xxxxxx-xx-xxx-2<br/>set /p key4=key:<br/>cls<br/>echo Thank you. We will check your key in the moment.<br/>pause<br/>set /a c="%key1%/%key2%'<br/>set /a d="%c%-%key3%<br/>set /a e="%d%/%key4%<br/>if "%e%"=="12" goto con<br/>goto CD<br/><br/>:con<br/>echo Thank you. we will begin installation in a moment<br/>pause<br/>What key are you attempting to use?the key is at the top of the bat file<br/>it is 03256-22-112-3<br/>Try removing the leading 0. So the first number would be 3256 instead of 03256.iI dont get a missing operator error any more but pause command at the end is not working.Sometimes the /a switch of the set command can confuse numbers with leading zeros with something else that requires more operators.Here's your problem-<br/><br/> Code: <a>[Select]</a>set /a c="%key1%/%key2%'<br/>set /a d="%c%-%key3%<br/>set /a e="%d%/%key4%<br/>1. The missing operator message is caused by those quotes which should either not be there (preferably) or at least match them start and end if you insist on having them (why?)<br/>2. A leading zero causes set /a to read the number as an octal value.<br/>3. See below <br/><br/> Code: <a>[Select]</a>echo off<br/>rem correct key is 03256-22-112-3<br/>rem therefore...<br/>set key1=03256<br/>set key2=22<br/>set key3=112<br/>set key4=3<br/><br/>rem neutralize any leading zeroes for each key<br/><br/>rem key1 has 5 digits so add 100000 (by prepending a 1)<br/>set key1string=1%key1%<br/>rem now take it away again with set /a<br/>set /a key1=%key1string%-100000<br/><br/>rem key2 has 2 digits so add 100 (by prepending a 1)<br/>set key2string=1%key2%<br/>rem now take it away again with set /a<br/>set /a key2=%key2string%-100<br/><br/>rem key3 has 3 digits so add 1000 (by prepending a 1)<br/>set key3string=1%key3%<br/>rem now take it away again with set /a<br/>set /a key3=%key3string%-1000<br/><br/>rem key4 has 1 digits so add 10 (by prepending a 1)<br/>set key4string=1%key4%<br/>rem now take it away again with set /a<br/>set /a key4=%key4string%-10<br/><br/>echo Numerical values:<br/>echo key1=%key1%<br/>echo key2=%key2%<br/>echo key3=%key3%<br/>echo key4=%key4%<br/><br/>set /a c=%key1%/%key2%<br/>echo Arithmetic operation (1) %key1%/%key2%=%c%<br/><br/>set /a d=%c%-%key3%<br/>echo Arithmetic operation (2) %c%-%key3%=%d%<br/><br/>set /a e=%d%/%key4%<br/>echo Arithmetic operation (3) %d%/%key4%=%e%<br/><br/>if "%e%"=="12" echo Correct!<br/><br/><br/> Code: <a>[Select]</a>Numerical values:<br/>key1=3256<br/>key2=22<br/>key3=112<br/>key4=3<br/>Arithmetic operation (1) 3256/22=148<br/>Arithmetic operation (2) 148-112=36<br/>Arithmetic operation (3) 36/3=12<br/>Correct!thank you it works great<br/>does it need modification if the first <a href="https://interviewquestions.tuteehub.com/tag/group-245646" style="font-weight:bold;" target="_blank" title="Click to know more about GROUP">GROUP</a> has 6 digits ex 123456 Quote from: mat123 on March 06, 2010, 02:54:46 PM</p><blockquote>does it need modification if the first group has 6 digits ex 123456<br/></blockquote> <br/>It should be obvious that the answer is "yes". I thought I had provided enough clues in the <a href="https://interviewquestions.tuteehub.com/tag/rems-3789721" style="font-weight:bold;" target="_blank" title="Click to know more about REMS">REMS</a>. Study them.<br/>i have a new problem any other key other than the 03256 key doesn't work ex 22428-89-156-8<br/>22428/89=252<br/>252-156=96<br/>96/8=12Are you sure?<br/><br/> Code: <a>[Select]</a>Numerical values:<br/>key1=22428<br/>key2=89<br/>key3=156<br/>key4=8<br/>Arithmetic operation (1) 22428/89=252<br/>Arithmetic operation (2) 252-156=96<br/>Arithmetic operation (3) 96/8=12<br/>Correct!it works now must have been something with my computer<br/>and is there any programing errors in this code for the key generator<br/><br/>echo off<br/>:A<br/>cls<br/>Set /a key2=(%Random% %%89)+10<br/>Set /a key3=(%Random% %%899)+100<br/>Set /a key4=(%Random% %%9)+1<br/><br/>set /a e="12"*"%key4%"<br/>set /a d="%e%"+"%key3%"<br/>set /a key1="%d%"*"%key2%"<br/>echo your key is %key1%-%key2%-%key3%-%key4%<br/>pause<br/>goto a<br/>well, it produces keys...<br/><br/>why are you using those quote marks?<br/>oops read the page for the set command wrong</body></html>


Discussion

No Comment Found