EggXpert.com

The platform that enables you to build rich, interactive communities
Welcome to eggXpert.com. Sign in | Join | Help
in Search
Advanced Search

DOS Batch

Last post 06-09-2008, 8:54 AM by MMaguire. 10 replies.
Sort Posts: Previous Next
  •  04-28-2008, 12:11 PM 312896

    DOS Batch

    I am looking to get a simple DOS batch program to ask for a user input then verify that it is what is the person typed, and if it is correct to what it is suppose to be it would run a certain command, but id it was not correct it would ask 3 more times then it would run a different command.

    Example:

    "mark" signs on in the morning opens this program types "marj" miss spelling his name would give him 3 more tries, at the end of 3 tries it would run the shutdown command and make him wait till it restarts to try again.

    But say "mark" runs the program and types "mark" correctly it would start the drive mapping command in DOS to give him access to his Drives.

    I want to make it so that I have more then one user input option because different users need access to different shares.

    I have considered doing a choices menu, but I want to make it some what secure so if a unauthorized person gets on they can’t just see a name and choose it to have access.

    I also know that anyone that has any computer skills can just edit the BATCH file and see the choices, security is not major concern, it’s just for convenience.

    I need this for a public computer that has a generic logon other wise i would just use active directory to manage my maped drives in there profile.


    Those who dont learn from the past are doomed to repeat it.
    Filed under:
  •  05-02-2008, 11:58 AM 315253 in reply to 312896

    Re: DOS Batch

    Do you have anything written already so we can see the code, or are you starting from scratch?

    -Mike 


    Remember to rate good helpful posts!
    For Some Tutorials Check Out My Tutorial Site:Team Tutorials

  •  05-02-2008, 4:49 PM 315390 in reply to 312896

    Re: DOS Batch

    Let me think on this, it should be easy to do with a series of "if then" commands.

    (input "mark" if "mark" then allow (whatever the map key is) if not "mark" then revert input

     I know that is not exactly correct and I am trying to remember how to limit the reversion to just three tries.

    Wow it has been a loooong time :-) Some other old fa&t like me maybe able to assist.


    Asus Commando, QX6700@2.93, 4GB Corsair PC28500 Dom, Tt Armor case, BFG 1KW PSU, BFG 8800GTX OC, 2 Raptors in RAID 0 for OS and Apps & 2 Raptors in SATA for music and graphic files and a WD7500AAKS (.75Tb) for large files, video files and back up, X-Fi, 2 Samsung monitors 245t and 244t's @ 1920 X 1200, Plextor opticals, Aerocool, Zalman, Etc. Vista Ultimate SP-1
  •  05-06-2008, 9:50 AM 317219 in reply to 315253

    Re: DOS Batch

    MMaguire:

    Do you have anything written already so we can see the code, or are you starting from scratch?

    -Mike 

    This is the Code i have been working with, i have been just trying to get it to recognise a file and move on but that dosen't even seem to work. I know its going to be some "If then" style command but i just cant seem to get them right.

    --------
    @echo off

    IF EXIST c:\signature.bmp THEN GOTO access
    IF NOT EXIST c:\signature.bmp THEN GOTO test2

    :access
    echo "Password Accepted all network drives avalible"

    pause

    echo "Loading Network Drives"

    NET TIME \\xxxxx /Set /yes
    net use g: \\xxxxx
    net use h: \\xxxx
    net use m: \\xxxx
    net use s: \\xxxx /y

    pause

    :test2
    echo "The file did not exist"
    pause
    exit


    Those who dont learn from the past are doomed to repeat it.
  •  05-31-2008, 9:45 AM 329845 in reply to 317219

    Re: DOS Batch

    Sorry for the delay, i got busy then forgot about this issue. The following code works fine, all you have to do is add you things you want to do within the parenthesis.

    @echo off

    if exist "C:\test.txt" (
        echo File Exists


    )

    if not exist "C:\test.txt" (
        echo File Does Not Exists
    )


    Hope this helps you out. 

    -Mike


    Remember to rate good helpful posts!
    For Some Tutorials Check Out My Tutorial Site:Team Tutorials

  •  06-03-2008, 5:35 PM 331658 in reply to 329845

    Re: DOS Batch

    Cool that code worked, is there a way to take it one step further like making it ask for user input text before going to the check to see if a file exist part?

    like i want to have it ask for a password, if the password is correct it will run one command. i.e. setup network drives

    but

    if the password is not right it would run another command that would run the shutdown command.

    I know the password would be plain text in the BAT file i dont really mind that, cuz the passwords are there just to prevent "Joe schmo" from walking up and having full access to the network.  the one reason why i diden't just do a choices menu.

     


    Those who dont learn from the past are doomed to repeat it.
  •  06-03-2008, 7:26 PM 331710 in reply to 331658

    Re: DOS Batch

    Try this:

    @echo off

    :prompt
    echo Password:
    set /p Input=
    if "%Input%"=="password" (goto correct)
    if not "%Input%"=="password" (goto incorrect)

    :correct

    if exist "C:\test.txt" (
        echo File Exists
        pause
        exit
    )

    if not exist "C:\test.txt" (
        echo File Does Not Exist
        pause
        exit
    )

    :incorrect
    echo Password Incorrect, Please Try Again
    pause
    cls
    goto prompt

     It works for me and I don't know of an easier way to do it. Let me know if you have problems or don't understand why the above code works. It's been a while since I worked with DOS, this has been fun. Big Smile

    -Mike


    Remember to rate good helpful posts!
    For Some Tutorials Check Out My Tutorial Site:Team Tutorials

  •  06-04-2008, 9:44 AM 332010 in reply to 331710

    Re: DOS Batch

    WOW the code worked out great, its nice to know that someone in this world other then me knows DOS still.  in a way i miss it...LOL

    just curious you might know this fast then me.

    is there a way to put a certin number of password retries say like 3 then the bat does something else like for a restart on the computer?

    I was thinking of adding some kind of an Errorlevel but i dont think that will work becuse its not really an error, any ideas?  and honestly i dont really think it is even possible.  I might have to move up to Visual Basic or C to get what i want.


    Those who dont learn from the past are doomed to repeat it.
  •  06-04-2008, 4:03 PM 332205 in reply to 332010

    Re: DOS Batch

    This should do it for you. As you mentioned - this should NOT be relied on to be secure as it will be human readable if opened. Ohter than that, let me know if you have issues.

     

    @echo off
    set t = 1

    :prompt
    cls
    echo Password:
    set /p Input=
    if "%Input%"=="password" (goto correct)
    if not "%Input%"=="password" (goto incorrect)

    :correct

    if exist "C:\test.txt" (
        echo File Exists
        pause
        exit
    )

    if not exist "C:\test.txt" (
        echo File Does Not Exist
        pause
        exit
    )

    :incorrect
    cls
    echo Password Incorrect, Please Try Again
    pause
    set /A t=t+1
    if "%t%"=="3" (goto shutdown)
    if not "%t%"=="3" (goto prompt)

    :shutdown
    cls
    echo Too Many Attempts. System will now shutdown.
    pause

    Good luck.

    -Mike

    (Edit - It posted the code all screwed up - fixed it and re-posted.)


    Remember to rate good helpful posts!
    For Some Tutorials Check Out My Tutorial Site:Team Tutorials

  •  06-06-2008, 10:05 AM 333301 in reply to 332205

    Re: DOS Batch

    Mike Thanks for the help this did exactly what i was wanting.

    I know its human readable, but to someone that a total moron wont know how to read it, atleast i hope not....but never underestimate the power of stupid people in large groups.

    I'm just amazed that someone in this world still knows how to DOS batch program.  you are a god among computer gurus.

     Thanks again.
    -Mark A


    Those who dont learn from the past are doomed to repeat it.
  •  06-09-2008, 8:54 AM 334614 in reply to 333301

    Re: DOS Batch

    No problem. Hope if works out for you. Let me know if you need anything else. Good luck.

    -Mike


    Remember to rate good helpful posts!
    For Some Tutorials Check Out My Tutorial Site:Team Tutorials

View as RSS news feed in XML

 Home   Forums   Chat   Blogs   Newsletter   About 

 FAQ   Terms of Use   Privacy Policy   Contact Us 

©2008 Newegg, Inc. All rights reserved.