195 points by _ol1s 42 days ago | 15 comments
torphedo 42 days ago
Wow, this is the largest batchfile I've ever seen! And I thought my 200-ish line one from high school was pushing it. Honestly huge respect for having the dedication to go this far with batch. I knew about the pseudo-function-calling features and a little bit of the weird syntax, but just skimming there's a lot of stuff in here I haven't seen before. Usually people saying "X in Y KiB" are doing some crazy linker shenanigans, so this was refreshing.

Also, "Windows To Go" and "Windows To Stay" are really funny feature names.

Mogzol 42 days ago
Speaking of large batch files, if anyone has ever softmodded a Wii, there is a good chance you used ModMii, which is by far the largest batch program I've seen. The main script [1] is a batch file that clocks in at over a megabyte. I used to be pretty into the Wii modding scene and remember talking with the author of that script about random batch things a few times. I can't imagine maintaining a file that big.

[1] https://github.com/modmii/modmii.github.io/blob/master/Suppo...

sunaookami 42 days ago
Don't forget that it even has a GUI made with Wizard's Apprentice which is created and controlled by a similar large batch file: https://github.com/modmii/modmii.github.io/blob/master/Suppo... :D
nyanpasu64 42 days ago
It's sad that so many projects simply stopped updating a decade or more ago... the first 90% of work is building a USB loader and the second 90% is maintaining it, and neither the author nor I want to figure it out. I read online that SNEEK lets you screenshot games... it doesn't work (wrong filesystem? neek2o and sneek have a different feature set?). Also god all those Exception (DSI) and learning a decade later they were segfaults... yummy memory-unsafe embedded programming.

I found that ModMii leaked some global variables from a (failed) SNEEK install to a system menu mod('s help file), and being written in Batch certainly explains things...

sllabres 42 days ago
I once knew a (very old) old accounting system that had to work around a 64kB limit and therefor used a programmatically generated set of many hundreds batch files batch files calling each other (not containing the program logic of course). But each of them was less than 100 lines long.

But 27 kLOC for the WII thing or 3 kLOC for the recovery tool which even looks a bit more convoluted then the WII thing sounds interesting to maintain. On the other hand, if it works, no dependencies no 200 MB binary blob.

torphedo 42 days ago
21k loc, one file... dear god. that trumps it all, for sure. and wow, the repo is still getting active commits.
Kwpolska 42 days ago
"Windows To Go" is the official name for a former Windows feature.

Writing a Batch script of any length, let alone 3085 lines, is completely insane with PowerShell being part of the default install.

maccard 42 days ago
I write tools for video game studios occasionally. You can’t double click a ps1 script and have it run, and you need to change the execution policy for powershell scripts to run. Those two hurdles for non technical people mean that we still write batch scripts
TiredOfLife 42 days ago
But you can run .ps1 from .bat that you doubleclick.
kachapopopow 42 days ago
That still has the same issue. Powershell will refuse to run scripts that are not signed by default.
andy81 42 days ago
You can use the -ExecutionPolicy argument to get around that.

It's not a security boundary, just something to stop users accidentally opening an email attachment like they will with bat/vbs.

ffsm8 42 days ago
Which is pointless if it's only for powershell.... But hey, security theater is kinda the MO of Microsoft if you think about rotating password policies which have a maximum password length etc
naikrovek 42 days ago
Sign the powershell script. It’s not that large of a hurdle to get a code signing cert, though it certainly isn’t trivial.
lll-o-lll 42 days ago
Code signing certs must have the key HSM’d these days. It’s a big hurdle.
gloosx 40 days ago
You have to go through a humilating process to get it as well as pay few hundred $$$ to one of MS street vendors.
naikrovek 40 days ago
you have to prove who you are, yes. I don't know what you mean in the 2nd half of the sentence.
gloosx 33 days ago
lemme explain quickly: you have to prove a lot of different things on paper, not just who you are; in reality this is just a money-milking side-hustle business for Microsoft. The process I had to go through had many different steps but in the end it all just relied on a blind trust between me and vetting team from the first step.
naikrovek 33 days ago
lemme respond quickly: code signing certs are in use by many more than just microsoft. if i want a code signing cert from digicert, microsoft doesn't get any money, digicert does. i can use it for more than just powershell scripts, of course, i can sign anything. they are useful things to have. getting them is a pain in the ass, yes, but it's supposed to be. they want to filter out identity impersonators and do everything they can to issue a cert to a person that is who they say they are. that's the whole point of the cert, so that's why you must show all of that proof.
maccard 42 days ago
If you are writing a bat wrapper, you might as well write the wrapper in c# at that point (which I do for anything that requires a condition or a loop)
naikrovek 42 days ago
The threshold you’ve chosen is crazy low, for me.

A condition or a loop? You’re writing everything in C# then. Everything worth writing, anyway.

maccard 42 days ago
Pretty much, yep. The batch file is just for pre providing arguments and checking awkward error codes from robocopy
Firehawke 42 days ago
Not to get TOO far off topic, but you just reminded me of the 300+ line batch file I was using for my BBS back in the early 90s. Lots of errorlevel checks to handle door transitions, Fidonet, etc.

You could get some ridiculously complicated batch files if you really needed the added functionality.

efdee 42 days ago
Wow, unexpected trip down memory lane. Thanks.

Press ESC twice for nostalgia.

42 days ago
rosywoozlechan 42 days ago
There's no license specified for what it's worth.
theGeatZhopa 42 days ago
[flagged]
userbinator 42 days ago
AFAIK the "Windows Recovery Environment" is actually a stripped-down minimal version of Windows missing most of the normal userland and parts of the kernel, which people have extended and customised in various ways.
windozedev 42 days ago
The overall design was inspired by the simple text based ui of clockworkmod recovery for android. There are zero dependencies as well.
robotnikman 42 days ago
>clockworkmod recovery

Now there's something I haven't heard of in a while. I remember using it on the original Droid phone when messing with roms

holysheet 42 days ago
One of the more impressive shell based tools that I've tried. Fitting into 200 kilobytes is an accomplishment in and of itself. Clever.
arthur2e5 41 days ago
Really bad nitpick, but: I cringe at FOO'S-type plurals. Just break out of the uppercase and say VHDXs if you find VHDXS too confusing.

https://www.hamilton.edu/academics/centers/writing/seven-sin...

firecall 42 days ago
Looks cool, but what does this do that the standard Windows Recovery Environment Partition doesnt do?

Maybe situations where the standard recovery env is borked? Was that the case in the recent CrowdStrike debacle?

neRok 42 days ago
> Was that the case in the recent CrowdStrike debacle?

Nah, it still worked fine on my work laptop and allowed to boot in to safe mode, which also worked (didn't crash).

theGeatZhopa 42 days ago
The biggest 3. problems in resolving clownstrike debacle are to know what and where to delete (if you don't know, you also can delete everything as well), bitlocker locked hard drives and having a lot of VMs running on Windows out there.

The first problem, however, is more significant, but you even won't come to solving if you've encrypted filesystem. And then you have to do it for each and every device/VM. It's just too much.

if you could boot into safe mode, then you already knew what to do and what to delete. Just imagine - bsod - you don't know why. A hint may be shown ;)

4jck 42 days ago
can I use this to install monitor drivers? make a bootable usb, add the installer onto the bootable usb and install the firmware? https://www.lg.com/au/support/product-support/cs-32GS95UE-B....

I thought about doing it through WINE, but that kinda scares me.

unfortunately my monitor received new firmware only installable through an exe, I only have my linux desktop

zxexz 42 days ago
My process for this is usually: - Poke at the EXE for a few hours to days. Sometimes it's just a self-extracting executable and you can just find the raw firmware binary. Sometimes you have to spend a few days relearning the basics of R2/Ghidra, and eventually can grab the firmware. - Then, if you've found it, figure out how to load it. When you think you have an idea, make sure it's really late and you're deliriously tired, so you're SURE you can do it without bricking it. Plus, where's the fun in not bricking it? You can always take that random Pomona SOIC knockoff clip and start dumping random ROMs off whatever chips. - Finally, if you were awake enough to not fall for the previous step - scrap all the work you've done, and commit to spending a while figuring out how to create a bootable windows USB. Or, if you can't get that to work for one of the many possible reasons, borrow a windows laptop. But you're probably too tired for that at this point anyway, so create a windows VM in QEMU, and repeatedly restart your machine as you mess with configs to get passthrough working for whatever you need to get the VM to connect to the device. Launch the utility, start the EXE - it starts working. Get so excited, you accidentally disconnect everything halfway through. Somehow the monitor seems to still work, but you swear there's just something not quite right about it. A few years later, take out the SOIC clip again. (based on an agglomeration of my personal mishaps)

In all likelihood, yes - this project will likely allow you to do that perfectly fine! But I'd be prepared for the installer to be total bloatware that doesn't work or works for most of the process before something goes wrong.

aspenmayer 41 days ago
Sometimes simple utilities like this are runnable under FreeDOS/MS-DOS booted from a USB flash drive and/or CD. Other times, you need Win32, and would use something like modern Hiren’s Boot CD, which is Windows 10 based iirc, unlike the original releases which were XP based iirc.
windozedev 42 days ago
There's a few ways you could do it, but it's a windows command shell script and only works under windows.
ChoGGi 42 days ago
If you're okay with third party software, you can make a bootable usb to update firmware from.

https://www.hirensbootcd.org/

proneb1rd 42 days ago
Insane. 3k loc shell script. I admire people that can maintain things like this. For me it’s unapproachable hot mess.
diggan 42 days ago
Is it really that unapproachable? I confess, I also prefer files that aren't 3k lines long, but when I have to deal with them, I basically deal with them as I deal with many files, one tab/split per "area" I want to work with. So if I'm working with three areas, I have three splits open that are focused on each area, and jump between the splits. Basically the same as if it was three files.
letaem77 42 days ago
What a name!
42 days ago
heraldgeezer 42 days ago
Reminds me of stuff like hirens boot cd but this seems more complex to use
42 days ago
42 days ago
kosolam 42 days ago
Eli5?
windozedev 42 days ago
Extract the zip into a new folder. Insert a w10/w11 disc or mount an ISO. Enter basic mode, it will take you through the steps.
zx1000 42 days ago
Dude...