Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Could a batch file wipe out a Windows install?

12 May 2017   #1
Foebane

Windows 7 Ultimate x64
 
 
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 System SpecsSystem Spec
.
12 May 2017   #2
samuria

win 8 32 bit
 
 

A batch file can run any CMD so it can destroy the system the only thing stopping it is permission on system folders
My System SpecsSystem Spec
12 May 2017   #3
Megahertz07

Windows 7 HP 64
 
 

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 System SpecsSystem Spec
.

12 May 2017   #4
RolandJS

Windows 7 Professional 64-bit
 
 

Going forward, be like me, make full images of OS and Data partitions onto external media just before experimenting
My System SpecsSystem Spec
12 May 2017   #5
Foebane

Windows 7 Ultimate x64
 
 

Quote:
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 System SpecsSystem Spec
Reply

 Could a batch file wipe out a Windows install?




Thread Tools




Similar help and support threads
Thread Forum
Windows Update - Win 7 Ent x64 - create batch file to install updates
Greetings, new to the forum. I apologize in advance as I'm sure this topic has been posted before, but didn't find anything that addressed this formally... So, the idea is that my company has a ton of desktops, connected to a domain, most of which do not have over 2gigs of RAM on them. When said...
Windows Updates & Activation
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Wipe HDD and re-install Windows OEM along with recovery partition.
Hello everyone! I am using a DELL INSPIRON N5010 series notebook. Have been using it for about 3 years now and for some reason I want to completely wipe my HDD and clean install windows along with the recovery partition. What I plan to do is take out my HDD, plugin it in to a SATA to USB...
Backup and Restore
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
Want to wipe RAID 1, install Windows 7 64 bit
Hi all, I want to upgrade from my 32 bit Vista to 7. I have a RAID 1 of two 320 GB drives, and I want to reformat it, and clean install windows 7. Will the RAID 1 be kept? Or do I have to reconfigure it on install? Thanks.
Installation & Setup


Our Sites

Site Links

About Us

Find 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 09:44.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App