87

I have an older laptop running Windows Vista, from about 2005 and I was fooling around with it a little bit. In a moment of sheer stupidity, I created a Batch file and put the following code in it:

%0|%0

I ran this and I had to restart my laptop. However, I decided to continue upon this destructive path and put the Batch file in the Windows Startup folder. Now I can't login without it destroying my laptop.

How can I remove this forkbomb from the Startup folder?

8
  • 41
    Also, this is a brilliantly simple way to destroy someone's computer. I'll try to remember this one just incase I ever meet someone that I really, really hate and I get 30 seconds with their computer. You could even use live boot media to access the filesystem and create the file without needing a password.
    – Keavon
    Commented Aug 23, 2015 at 4:22
  • 9
    This is beautiful Commented Aug 23, 2015 at 19:21
  • 4
    @Keavon Better yet, turn it into ransom-ware. ;)
    – jpmc26
    Commented Aug 23, 2015 at 23:28
  • 9
    what does this line of code actually means? Commented Aug 24, 2015 at 13:03
  • 9
    @EhsanSajjad - every time it executes, it spawns two new instances of itself. (which each spawn new instances, etc.) Eventually it consumes all available resources, and the computer becomes unusable. In a batch script, %0 stands for the executing batch script. Commented Aug 24, 2015 at 14:27

5 Answers 5

75

How to remove a forkbomb from the Startup folder?

Start your PC in "Safe Mode" (Startup programs do not run in safe mode, and only the basic drivers needed to start Windows are installed).

Then you can delete the offending batch file.


How To Start Windows Vista in Safe Mode

  1. To begin entering Windows Vista Safe Mode, turn on or restart your PC.

  2. You will see the Splash Screen

  3. Before the Windows Vista splash screen appears, press F8 to enter "Advanced Boot Options"

  4. Select "Safe Mode" and press Enter

Screenshots:

enter image description here

**strong text**

Source How To Start Windows Vista in Safe Mode

0
19

You can skip loading the contents of the Startup folder by holding down Shift as the computer starts and logs in. (Note that this doesn't work for startup applications loaded from the Registry or other locations, only the actual Startup folder.)

5
  • 2
    Have you actually tried this or did you just read it somewhere? I just tried it on Windows 8.1 and it didn't seem to work.
    – user541686
    Commented Aug 22, 2015 at 20:35
  • 3
    I've done this before on Windows 7 and it works fine. You have to press and hold Shift the whole time after you press Enter on your password until the desktop appears, maybe a bit longer to be safe.
    – nhinkle
    Commented Aug 23, 2015 at 5:57
  • I have gotten it to work before, but I can't say for sure which versions of Windows. Commented Aug 23, 2015 at 18:26
  • Are you sure it skipped the contents of the startup folder? I feel like when I tried it, it skipped the registry but not the startup folder. @nhinkle
    – user541686
    Commented Aug 24, 2015 at 2:19
  • @Mehrdad It was definitely the folder in either 98 or XP (last time I had to use it), no idea if it's changed since then
    – Izkata
    Commented Aug 25, 2015 at 17:44
9

Try booting your laptop in Safe Mode by pressing F8 during the bootup sequence, from there, just locate the file in your Startup folder and delete it.

If you're worried about accidentally opening it, or something similar, you can boot up in Safe Mode with Command Prompt (Provided you can use Command Prompt), and delete it that way, instead.

Even safer than that would be to take the hard drive out and connect it to a machine that cannot open a batch file, thus unable to reactivate the sequence, and remove it that way.

If that's unavailable, you could always try and re-image the drive.

8
  • 3
    If you can re-image the drive by booting into another tool somehow then you can just delete the file from there.
    – user541686
    Commented Aug 22, 2015 at 20:09
  • If you boot to a live CD it's much safer than taking the hard drive out and re/unmounting it. Not like Live CDs can. Commented Aug 22, 2015 at 21:10
  • Kinda confused how this is a different answer other than that point though to be honest. Commented Aug 22, 2015 at 21:10
  • I have the same opinion on the duplicate answer you posted after mine, @MichaelBailey
    – Quill
    Commented Aug 22, 2015 at 22:30
  • What? This doesn't list Live CD as an option. A noobie taking a hard drive out and setting it up for another machine should probably come after a live CD. Also I thought I was first answer but hey that can be a network bug for all I know so that's whatever Commented Aug 22, 2015 at 23:16
7

Your best bet is to boot into Safe Mode or to a recovery disk or a linux live CD and remove it.

To boot to Safe Mode go ahead and I believe hit F8. Here's instructions, but the big thing is to strike F8 mid-boot.

The command to delete a file in Windows is del and in Linux is rm. Note in Linux you may be better off doing it though their file manager since if you don't know Linux you'll have to mount the disk and all that. The recovery console command prompt is what you'll want in the Windows disk.

5

In addition to the other answers: if by some chance, your problem lies in the registry (for instance, as in @isanae's comment on the accepted answer), you can edit the registry offline either by booting to another install of your version of Windows, or by using a setup/WinPE environment CD.

In short, open up the registry editor in your alternate OS (from WinPE or a setup disc, you can press Ctrl+F10 to open up a command prompt, then enter "regedit"). From there, you can create a new node in the registry tree, then use File -> Load Hive to choose the corresponding files for offline registry editing as follows:

[HKEY_LOCAL_MACHINE\SYSTEM] (%windir%/system32/config/SYSTEM)

[HKEY_LOCAL_MACHINE\SOFTWARE] (%windir%/system32/config/SOFTWARE)

[HKEY_USERS.Default] (%windir%/system32/config/DEFAULT)

[HKEY_CURRENT_USER] (%userprofile%/ntuser.dat)

From here, you can make whatever edits you need (SOFTWARE\Microsoft\Windows\CurrentVersion\Run, for example, holds your startup programs), and then save/close the hive you opened back to the same file.

4
  • 2
    Note that if you use this method to fix user-local registry settings from a second user account on the same Windows install, it's absolutely essential to unload the hive before attempting login. If you leave the hive mounted, it can't be loaded to the correct location under HKEY_USERS and Windows will permanently change the profile to point to a newly made mostly empty hive. (mostly empty = same state as a user logging in for the first time ever). Just retracing your steps won't fix it.
    – Ben Voigt
    Commented Aug 24, 2015 at 22:57
  • @BenVoigt Interesting issue that I wouldn't have thought of. If Windows does permanently change the profile, do you happen to know where the new hive (assuming it doesn't overwrite the already-mounted old hive) is created/stored?
    – Shamtam
    Commented Aug 25, 2015 at 4:57
  • If I remember right (but it has been a few years) the new registry hive file goes in the same directory but with a numeric file extension.
    – Ben Voigt
    Commented Aug 25, 2015 at 5:19
  • You may also need to look in WOW6432Node, I'd assume that the startup-run stuff in there will also be honoured Commented Aug 25, 2015 at 8:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .