Could a batch file wipe out a Windows install?


  1. Posts : 20
    Windows 7 Ultimate x64
       #1

    Could a batch file wipe out a Windows install?


    Yesterday I had a collection of batch files which worked, but I wanted to refine them and make them more robust by using variables like %~1. The batch files involved totally removing old folders and subfolders in a specified path and replacing them with ZIP files from a backup.

    Well, I converted them fine and they ran with variables provided from a secondary batch file.

    HOWEVER, at one point I thought I'd run the original file, and next thing I know I'm getting a lot of unusual filenames from what seems like a system folder and "ACCESS DENIED" all over them, and I realised it was going to try to wipe out my system folders instead, all because the variables were blank.

    I stopped the batch file and discovered that apps in "Program Files" had been deleted, but Windows was still operating. I didn't reset, but ran System Restore instead to a Restore Point that had been made just yesterday morning, and whilst it restored fine (I hope) it took a long time to initialise.

    As of now everything seems to work again, but my "PerfLogs" file in the C:\ root is gone, and I only hope it's not important. And yes, I immediately put in conditional commands in the batch file to exit if there were no variables, so no more problems there.

    But what could've happened otherwise? Can an installation of Windows be crippled or even wiped out by an errant batch file?
      My Computer


  2. Posts : 3,788
    win 8 32 bit
       #2

    A batch file can run any CMD so it can destroy the system the only thing stopping it is permission on system folders
      My Computer


  3. Posts : 7,351
    Windows 7 HP 64
       #3

    Windows don't allow to modify or delete files that are in use, so most system files will be intact, but it doesn't mean that a severe damage can be avoided.
    I'll suggest to run System File check
    sfc /scannow
      My Computers


  4. Posts : 2,774
    Windows 7 Professional 64-bit
       #4

    Going forward, be like me, make full images of OS and Data partitions onto external media just before experimenting :)
      My Computer


  5. Posts : 20
    Windows 7 Ultimate x64
    Thread Starter
       #5

    IF "%~1"=="" EXIT /B
    IF "%~2"=="" EXIT /B
    DEL /F /S /Q "%~1\%~2\*.*"
    RD /S /Q "%~1\%~2"
    MD "%~1\%~2"
    ATTRIB +A "%~1\%~2"
    "C:\Program Files\7-Zip\7z.exe" X "%~1\ZIP\%~2\*.zip" -O"%~1\%~2"
    This is the batch file responsible, with the protection added. I wouldn't advise running this without the IF statements. What sort of damage could this file do?
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:03.
Find Us