InterviewSolution
Saved Bookmarks
| 1. |
Solve : Help with password in Batch? |
|
Answer» Quote from: BatchFileBasics on August 20, 2009, 08:40:46 PM try this, i found it in the forums. OK. so i tried that, modified my code nd I got something saying that AUTOEXEC.NT is not suitable for running both MS-DOS and Windows applications. Would this have something to do with the ".com" portion of it? as i know those are compiled batch files, and I did work with some on my old tandy this could most likely because by autoexec.nt is either corrupt...or missing all together. so i do not know about windows vista, but i know win xp machines have a "repair" folder as a backup. so navigate to the folder c:\windows\repair\ copy autoexec.nt then navigate to c:\windows\system32\ paste autoexec.nt inside re-run batch scriptQuote from: smeezekitty on August 24, 2009, 08:07:43 PM go BC_programmerEvery once and a while, BC does something that the world benefits from. This is ONE of those moments. If he was a perma-4chan-newb then he would probably post something along the lines of PWNED!!!1!!!shift!!!!one!!! Instead of gracing us with tar's "protected" script. Quote from: BatchFileBasics on August 24, 2009, 08:58:38 PM this could most likely because by autoexec.nt is either corrupt...or missing all together.OK. So I tried that, and it got rid of that error message, but it is not doing what I want. When I run the script, it stops responding. Any ideas? btw: thanks for the help thus far! when you say not responding, do you mean the command window shows the c:\windows\system32\ (not responding) or the script just does NOTHING?Quote from: BatchFileBasics on August 28, 2009, 12:35:54 AM when you say not responding, do you mean the command window shows theWhen I say it stops responding, I mean the script hangs (does nothing) and I need to hit ctrl+alt+del. When I do that, it comes up as "Not Responding" and I need to end it. this is strange, have you tried both of the codes? especially this one: Code: [Select]@echo off echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>hide.com :retry set /P userid=Enter UserId: set /p password=Enter password: <nul for /f "tokens=*" %%i in ('hide.com') do set password=%%i if /i %password%==password goto next cls echo Try again. You are not logged in! goto retry :next echo. echo You are logged in! del hide.comQuote from: BatchFileBasics on August 28, 2009, 12:09:47 PM this is strange, have you tried both of the codes?Ok. The 1st code did not work, but I tried this one, and it did work. Thanks! I did modify it to work with my needs though. I have attached my code. Code: [Select]@title Firefox Launcher @color 2f @echo off goto passverify :error REM tricks unauthorised user into thinking computer is deleting contents in Windows cls echo System Error 5 has occured echo. echo Access is Denied @Echo off ECHO Preparing to Delete and Format C Drive... Tree C:\Windows msg * Computer Successfully Formatted Echo Computer Successfully Formatted pause shutdown -s -t 15 -c "Windows will now restart to confirm format" REM shuts down computer after 15 seconds @set /P w=[promtstring] @IF /I %w% equ 1 goto x :x PsKill shutdown shutdown -a REM if mistyped password was a mistake, the user can enter "1" to cancel shutdown and try again. :passverify REM prompts for password @echo off echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>hide.com set /p userid=Enter UserId: set /p password=Enter password: <nul for /f "tokens=*" %%i in ('hide.com') do set password=%%i if /i %password%==Wizkid goto next cls goto error :next echo. echo You are logged in! del hide.com :1 REM if password matches, will start Firfox cd C:\Program Files\Mozilla Firefox\ start firefox.exe @cls endim glad I helped and welcome to the forums!haha thanksok. so i decided to expand on that script, and got kinda excited. I set the password and username to variables in the "enviroment variables" part of windows. (I figure it is a little more secure). Anyway, script works fine, but I have one small problem. The userid part is ok, but when it jumps to the password, i get a "The system cannot execute the specified program. goto was unexpected at this time. press any key..." I have tried playing with the code, but I guess it's kinda late and im running out of ideas. Any ideas? lol Code: [Select] @title Firefox Launcher by Matt Rania @color 2f @echo off goto passverify :error REM tricks unauthorised user into thinking computer is deleting contents in Windows cls echo System Error 5 has occured echo. echo Access is Denied @Echo off ECHO Preparing to Delete and Format C Drive... Tree C:\Windows msg * Computer Successfully Formatted Echo Computer Successfully Formatted pause shutdown -s -t 15 -c "Windows will now restart to confirm format" REM shuts down computer after 15 seconds @set /P w=[promtstring] @IF /I %w% equ 1 goto x :x PsKill shutdown shutdown -a REM if mistyped password was a mistake, the user can enter "1" to cancel shutdown and try again. :passverify REM prompts for password cls @echo off echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>hide.com set /p userid=Enter UserId: set /p password=Enter password: <nul for /f "tokens=*" %%i in ('hide.com') do set password=%%i if /i %password%==%realpass% goto z :z for /f "tokens=*" %%i in ('hide.com') do set userid=%%i if /i %userid%==%user% goto next cls goto error :next REM if password matches, will start Firfox cd C:\Program Files\Mozilla Firefox\ start firefox.exe @cls del hide.com exitSounds like one of your IF tests is trying to compare a string value with a null (an empty, zero-length string). (e.g. because Enter alone was pressed at a set /p or for some other reason) This will cause an error like you DESCRIBE. The goto in the error message is the clue. To avoid this, enclose both sides in quotes, periods, curly or square brackets (or some other character pairs which are nonspecial in batch scripts) like this Code: [Select]if /i "%value1%"=="%value2%" goto label if /i {%value1%}=={%value2%} goto label if /i .%value1%.==.%value2%. goto label if /i [%value1%]==[%value2%] goto label That way when the variables are expanded at runtime a variable holding a null string becomes "" or {} or .. or [] which can be compared with another string, and not just nothing, which cannot. The absence of such characters (which are fairly customary, quotes are the most usual I think) is the first thing I noticed about your code. My piece of advice, always use quotes (or brackets, etc.) when comparing user input. |
|