• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

How can a batch file do this?!

Status
Not open for further replies.
Joined
Aug 13, 2009
Messages
3,493 (0.60/day)
Location
Czech republic
Processor Ryzen 5800X
Motherboard Asus TUF-Gaming B550-Plus
Cooling Noctua NH-U14S
Memory 32GB G.Skill Trident Z Neo F4-3600C16D-32GTZNC
Video Card(s) Sapphire AMD Radeon RX 7900 XTX Nitro+
Storage HP EX950 512GB + Samsung 970 PRO 1TB
Display(s) Cooler Master GP27Q
Case Fractal Design Define R6 Black
Audio Device(s) Creative Sound Blaster AE-5
Power Supply Seasonic PRIME Ultra 650W Gold
Mouse Roccat Kone AIMO Remastered
Software Windows 10 x64
I have a relatively simple batch file that prepares a Windows image with various tweaks and whatnot for unattended installation.
At the beginning, I make it delete the entire contents of a folder the files get initially copied to by doing this:
for /d %%j in (d:\win7\*) do rd /s /q "%%j"
del d:\win7\*.* /q
That's the only way I managed to figure out how to remove all the subfolders and files.

Now: for some super obscure reason I cannot understand, if you edit the batch file and save it while the batch is running, the damn thing wipes the ENTIRE disk clean.
Does anyone more knowledgeable have any idea why the heck does happens?
 
First time i hear someone editing a running batch file, but since it's possible, why not :)

What are the modifications you brought to this script when the recursive erase spread to the entire disk ?
 
That's the most bizarre thing - I didn't touch the deletion commands at all.
 
did you see this answer taken from stackoverflow ? :

The command interpreter remembers the line position it's at in the batch file. As long as you modify the batch file after the current executing line position you'll be fine.

If you modify it before then it will start doing strange things (repeating commands etc..)
 
and also

Actually, what it will do is the parser pointer will stay at the same index in the file, so adding/removing text before the index will shift what's under the instruction pointer. Weird things happen, indeed

that must be the culprit :) (that calls for troubles)
 
I still don't really understand why the damn thing decided to wipe the entire disk rather than, I don't know, re-wiping the folder in question again.
But it was a costy lesson - I lost 3 years worth of registry tweaks I used to apply to Windows images during installation, because for some weird reason the files were wiped so clean I couldn't even find them with recovery tool. Plus I had no backups of anything despite having 4TB space in the NAS.... (yes I am a retard)
 
Slightly OT but won't rd /s /q do what you want?
 
somehow the script instructions became unclear after you modified it on the fly, and the former command "mutated" into something more destructive.

As to why your recovery tool couldn't revive the deleted files, i think this recursive deletion gone crazy acted like a cut & paste, where all former files cease to exist on the source drive / partition.

You learned the hard way, sorry for this loss, it happened to all of us at some point :banghead:
 
Slightly OT but won't rd /s /q do what you want?
I'll give it a shot once I backup (cough) all my stuff :D
I wrote that part ages ago and never got back to it since.... it's most likely not ideal solution.

As to why your recovery tool couldn't revive the deleted files, i think this recursive deletion gone crazy acted like a cut & paste, where all former files cease to exist on the source drive / partition.
That's probably true, because 17GB worth of Skyrim mods became garbage data and got moved into Lightroom's catalogue folders... it's a damn voodoo I'm telling you.


I need to figure out a way to find out what the reg tweaks were. Best I can think of is exporting the entire registry of my father in law's recently installed notebook, and comparing them with default installation. 200MB worth of plain text... FML.
 
May I ask why one would still install win7 in mid 2017?
 
May I ask why one would still install win7 in mid 2017?

Last post was August 23, 2016. Unless you're going to offer something useful to the thread, please refrain from thread necro-ing. Thanks! :toast:
 
Status
Not open for further replies.
Back
Top