1.

Solve : Need Help with Command line on making folder hidden in a bat file?

Answer»

Im trying to make a password protected folder it went fine until i tryied to rehide the folder in the .cmd heres what i got
Code: [Select]@echo off
Echo.Please Enter PASS to CONTINUE....
:action
set /p pass=Password:
set userinp=%pass:~0,100%
if /i "%pass%"=="W" goto success
echo.incorrect
goto action

:success
Echo.Welcome MillerGram
echo.To rehide Folder type hide
attrib -h -s Hidden
set /p passa=:
set userinp=%pass1:~0,100%
if /i "%passa%"=="hide" goto hide
echo.what was that?
pause>nul
cls
goto success

:hide
attrib +h /d /s Hidden
goto success
The hide shortcut dosent seem to work any IDEAS?Quote from: millergram on January 25, 2011, 06:31:17 PM

The hide shortcut dosent seem to work any ideas?

Did it ever work?

Code: [Select]@echo off
Echo.Please Enter Pass to continue....
:action
set /p pass=Password:
set userinp=%pass:~0,100%
if /i "%pass%"=="W" goto success
echo.incorrect
goto action

The user is instructed to enter 'pass', but the if statement makes a compare to 'w'. Misleading the user is not recommended.

Code: [Select]:success
Echo.Welcome MillerGram
echo.To rehide Folder type hide
attrib -h -s Hidden
set /p passa=:
set userinp=%pass1:~0,100%
if /i "%passa%"=="hide" goto hide
echo.what was that?
pause>nul
cls
goto success

If the user should actually get here (see above), nothing particularly wrong in this section, just sloppy. Using set /p allows for a prompt message; you don't need the echo command.

Code: [Select]:hide
attrib +h /d /s Hidden
goto success

This is OK for what it does.

Questions:
What are these: set userinp=%pass:~0,100%
Userinp is prompted for but never used

There is no exit point to the logic. Once the user finally gets out of the :action tag, they get stuck bouncing around the :success and :hide tags.

Using passwords in a batch file is self-defeating. At some point the code will have to compare the user input to the actual password. Anyone with an editor or knows how to use the type command will be able to see how to move around in the logic.

You might consider making your code more generic. Prompt for the folder name, test if it exists, then proceed to hide/unhide it. Lose the passwords. Keep it simple.

Just a thought.




Thank You So Much
Still Got Tons To learn
Like I DINT already know that


Discussion

No Comment Found