A Simple Script to Free Resources in Windows


by
966w

I have a computer that largely consists of eight-year-old components, so maintaining a stable 60 frames per second can be a challenge.

I mainly play Overwatch, and while the general performance seems to be acceptable, I started to notice some weird intermittent dips in performance—of course at the worst possible moments.

Turns out iTunes and Dropbox have a habit of just destroying users’ CPU for no good reason, which means you can’t predict when they’re going to spring a surprise on you.

On top of that, multiple apps have no compunction about using up all your bandwidth to download updates in the background; even Blizzard’s own launcher has started hogging all my internet as Overwatch was running at a speed I didn’t think I had chosen.

Closing all these miscreants is a pain and a half, both the time it takes to do the basic housecleaning every time you want to play a stupid game, as well as having to remember your checklist of programs to close.

This is where I ran into .bat scripts and Windows’s taskkill command that makes it dead simple to write your own script to close all these programs with a simple click before each session.

Just save the contents of killresourcehogs.bat to a file with a file name of your choosing and hit it before you play your game. Of course, you’ll have to configure it depending on the programs you use and don’t use; you don’t want to close the Blizzard launcher as you’re about to play Overwatch for instance.

Another scenario where you may want to retain your optimal performance is when streaming, recording or watching a video online where CPU is alpha and omega.

If you plan on doing more with this, you can also call killresourcehogs.bat from another batch script to avoid repeating yourself:

call killresourcehogs.bat

Now go rank up.

Update: Turns out this script is also excellent for quickly closing programs that might use a lot of bandwidth if you’re on mobile data or a slow internet connection.

Repeal and delay

Dropbox in particular is an awful piece of software, and on every startup, it immediately starts indexing which smothers your CPU. Most of the time, the first thing people do when their computer boots is to open a browser. Why have anything else delay that.

Rather than have Dropbox and similar apps do this, some people like myself opt for not running these applications on startup.

But it’s not like they’re unimportant apps so this is just a frustrating compromise that has its own issues. I’ve had no small amount of sync conflicts because of this.

Instead, I figured out an alternative that’s not as frustrating:

  1. Don’t run a list of apps on startup
  2. Create a list of apps with a delay after startp
  3. Implement list with batch scripting
  4. Put .bat file in the Start folder

Here are some apps I don’t need to run at startup:

  • Backup software
  • iTunes(!)
  • Dropbox(!)
  • Battle.net
  • Discord

Starting applications is little different from using taskkill to tend them.

I’ll show you what my startup.bat looks like and explain it line by line:

  • @echo off: don’t print anything
  • timeout /t 120: sleep for 120 seconds before moving on
  • iTunes: Some apps can be started with just a name
    • /min: start minimized; doesn’t work with Discord and Battle.net, and makes iTunes act weirdly
  • Dropbox: Batch scripting supports environment variables

The last part I’ll break down in more detail.

First off, if a path has whitespace ( ) or dashes (-), you will need to put your path in quotes. Otherwise, you should not put it in quotes.

If an empty terminal window opens, it’s because you messed one of these things up in one of your lines (or several).

When you put a path in quotes, you will often need to add a title argument to start. I just give it an empty one ("").

I don’t want to give you a more general explanation of how it works; just write your script through trial and error and see whether it starts. I know I have.

In light of this, let’s go over our start scripts once again:

  • iTunes: is a known app, so we just use shorthand
  • Dropbox: path has no spaces or dashes so we don’t use quotes
    • We use an environment variable, since it’s easier and prettier
  • Battle.net: path has a space so we use quotes and the empty title
  • Discord: path has a dash so we use quotes and the empty title
    • We use an environment variable, since it’s easier and prettier

One annoying thing here is that Discord creates a folder for each new version of its app so you’ll have to manually update it each time.

If you check the file location of the app in the Start Menu, you’ll see this as target application:

%LOCALAPPDATA%\Discord\Update.exe --processStart Discord.exe

I haven’t been able to recreate the execution in a batch script, but maybe someone knows how to do it in a way that isn’t too complex.

Either way, here is a a tolerable, self-made, self-controlled, exportable, shareable way to delay apps from starting up to improve your experience. You should never allow a third-party tool to do this for you.

The Start folder (on recent versions of Windows) is

%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup

You can also just use Run (Win + R) and type shell:startup. Drag and drop a shortcut for your script and you’re done.

Your computer may seem fine and fast now, but just you wait.