1.

Solve : Creating a password protect batch file with a batch file?

Answer» <html><body><p>Hey everyone, I'm fairly new at programming at everything, but I'm trying to learn, so bear with me.<br/><br/>I created a batch file, for fun, to shut down a computer in 60 seconds, but creates a text file and a second password protected batch file to <a href="https://interviewquestions.tuteehub.com/tag/abort-366105" style="font-weight:bold;" target="_blank" title="Click to know more about ABORT">ABORT</a> the shutdown.<br/><br/>This is the code I've used.<br/><br/> Code: <a>[Select]</a>ECHO OFF<br/>MODE CON: COLS=70 LINES=6<br/><a href="https://interviewquestions.tuteehub.com/tag/title-246221" style="font-weight:bold;" target="_blank" title="Click to know more about TITLE">TITLE</a> Shutdown - By Matt<br/>START C:\Windows\System32\shutdown.exe -s -t 60 -c "Shutting Down"<br/>ECHO Warning! Your computer will shutdown in 60 seconds! &gt; shutdown.txt<br/>ECHO. &gt;&gt; shutdown.txt<br/>ECHO To abort, run the "abort" batch file on your desktop. &gt;&gt; shutdown.txt<br/>ECHO echo off &gt; abort.bat<br/>ECHO MODE CON: COLS=20 LINES=5 &gt;&gt; abort.bat<br/>ECHO title abort &gt;&gt; abort.bat<br/>ECHO color 9B &gt;&gt; abort.bat<br/>ECHO :Start &gt;&gt; abort.bat<br/>ECHO cls &gt;&gt; abort.bat<br/>ECHO set /p password="Password: " &gt;&gt; abort.bat<br/>ECHO if "%password%"=="qwerty" goto :correct &gt;&gt; abort.bat<br/>ECHO goto :Start &gt;&gt; abort.bat<br/>ECHO :correct &gt;&gt; abort.bat<br/>ECHO cls &gt;&gt; abort.bat<br/>ECHO echo Password correct! &gt;&gt; abort.bat<br/>ECHO C:\Windows\System32\shutdown.exe -a &gt;&gt; abort.bat<br/>ECHO pause \nul &gt;&gt; abort.bat<br/>ECHO exit &gt;&gt; abort.bat<br/>START C:\Users\%USERNAME%\Desktop\shutdown.txt<br/>COLOR 9B<br/>ECHO.<br/>ECHO --------------------------------------------------------------------<br/>ECHO Run abort.bat and enter the password<br/>ECHO Now press any key to delete the two files created by this batch file.<br/>ECHO --------------------------------------------------------------------<br/>ECHO.<br/>PAUSE<br/>DEL C:\Users\%USERNAME%\Desktop\shutdown.txt<br/>DEL C:\Users\%USERNAME%\Desktop\abort.bat<br/>EXIT<br/>It shuts down properly, creates and opens the text file properly, but I run into problems with the second batch file.<br/><br/>This is the code it puts into the second batch file:<br/><br/> Code: <a>[Select]</a>echo off <br/>MODE CON: COLS=20 LINES=5 <br/>title abort <br/>color 9B <br/>:Start <br/>cls <br/>set /p password="Password: " <br/>if ""=="qwerty" goto :correct <br/>goto :Start <br/>:correct <br/>cls <br/>echo Password correct! <br/>C:\Windows\System32\shutdown.exe -a <br/>pause \nul <br/>exit<br/>The password portion of the file won't rune because it doesn't add Code: <a>[Select]</a>%password% into it.<br/><br/>Does anybody know of a way to make it add that into the second batch file, or a second way of writing a password command that will work?<br/><br/>Thanks,<br/>- MattI wrote a complete explanation of why you had this result and how to avoid it BUT I had second thoughts. I deleted it. This sounds like a <a href="https://interviewquestions.tuteehub.com/tag/prank-592785" style="font-weight:bold;" target="_blank" title="Click to know more about PRANK">PRANK</a>.<br/><br/><br/>What do you mean a prank?<br/><br/>Please help me find a way to fix this? I'm just learning and created a file to test my knowledge.Solved Thanks to "mat123".<br/><br/>Thanks so much.<br/><br/>The solution was to put %%password%% instead of just %password%. Quote from: MattPwns on July 02, 2010, 02:13:15 PM</p><blockquote>What do you mean a prank?<br/><br/>Please help me find a way to fix this? I'm just learning and created a file to test my knowledge.<br/></blockquote> <br/>A prank is where you put a script on somebody elses computer for a joke to see their alarm and surprise. So that you pwn them. (Your name tells me a lot)<br/><br/>Way to help a prankster mat123.<br/>but, it would show them how to stop it...<br/><br/>I created this to test my knowledge as i said before, and now i am trying to find a wait for it to start automatically after 10 minutes or something.<br/><br/>Ill probably put a new batch file into the startup folder, and run wait command of some <a href="https://interviewquestions.tuteehub.com/tag/sort-238033" style="font-weight:bold;" target="_blank" title="Click to know more about SORT">SORT</a> then open this one.<br/><br/>Again bro, it's just for fun and personal <a href="https://interviewquestions.tuteehub.com/tag/use-241643" style="font-weight:bold;" target="_blank" title="Click to know more about USE">USE</a>.</body></html>


Discussion

No Comment Found