You know what really grinds my gears? Opening game clients one by one when I want them all to open and update. So I engaged in a little every-day-scripting to stop the grinding. “Code” inside.
I make frequent use of five game clients: Steam, Origin, Battle.net, GOG Galaxy, and uPlay. I’m also nit-picky and cannot stand applications that boot with my computer – it’s not always a given that I’m going to do “Y” so why do I want “Y-client” to run on every boot? This means that when I do I’m looking to play a game, I need to click on /five/ different icons in my taskbar. To make things worse, I like the “expanded taskbar buttons” thing so sometimes, just to screw with me, a button will expand as the application opens and I click on it again instead of on the icon I actually wanted, which was there just a moment ago. Maddening!
So I fixed it. I made it better. I made it one click. Two if you prefer to be slow and not use keyboard shortcuts. I consider this awfully clever, even though I know full-well it’s bloody simple and the sysadmin in me is saying things like “is this even worth mentioning?” and I reply with something about not having anything else to talk about anyway so yeah it is.
What’s the magic thing, then? I’m glad you asked. It’s a batch script, which runs all of my favourite game clients for me so they’ll open and update (because of course there are updates, you last ran it ages ago/yesterday). Want to replicate? Well…
The script’s been stuck on my GitHub now. You should go there to get it.
Basically the script calls the various .exe files for each client I want to launch. Though despite the simple premise, there was a deceptive amount of work that went into this. First of all, the easy route of calling each .exe by just listing the path to it was not effective because that method would wait for the starting application to return an exit code before the script moves on. As I quickly realised, not all of these game clients provide such an exit code, so the script gets hung up on them until the application is closed. So internet-adventure zero was finding a way to start the application and move on, exit code notwithstanding. As usual, this involved at least two Ducks, chased by three questions over two StackExchange communities (the answer’s in all three). I may have overdone the search (let’s say I was pattern-matching). Essentially, the
start command will execute an application and move on, but I needed the first set of
"" (which is intended to provide a “title” for the opening window’s title bar) before specifying the executable path, because that path contains spaces so also needs to be wrapped in quotes (else
start will think the path is the title, if I didn’t specify the blank one).
Next, because I wanted the script to be all neat-o, I needed a way to introduce a little pause between each client’s launch. This is more complicated than you may think, because Windows system functions like
sleep don’t function quite as simply as one may hope, and more importantly might not even be available your Windows system. For example,
pause will actually stop your script until you press a key, which is not ideal for a script meant to achieve automation…
Sleep almost makes it, but unfortunately it’s not baked in to Windows, rather being available through resource kits and for something this simple, software dependency was out of the question.
Timeout gets even closer by being built-in (from Windows 7 onward) but I didn’t want my pause to generate an output. So this is where another Duck brought me a vaguely familiar, invaluable scripting resource, the Rob van der Woude Scripting Pages. More specifically, the wait page which details the
choice method of creating a delay in a script, and I really like the elegance of it (especially over the more widely-known methods of using
netsh – there’s something I dislike about engaging the network stack for something that has no business making network calls).
Components in-hand, I wrote out the script with some
echo‘s to flavour it, and I’m quite pleased with the result. It’s a much nicer way of running all of my clients. For the cherry on top, I used the services of game-icons.net to generate an icon for the script (the green thing up there), and then ran the resulting .png file through Convertico to generate an .ico file. I saved the script and icon in a central spot on the system (I use
C:\scripts\ for this) and created a shortcut file for the script that uses the icon. To get the shortcut to display in my Start menu on Windows 10, I copied the shortcut file into
C:\Users\(your-username)\AppData\Roaming\Microsoft\Windows\Start Menu\Programs. That made it appear in the All Programs list, and from there I pinned it to the Start menu. I haven’t figured out how to pin a shortcut to the taskbar yet… Windows 10 is oddly difficult about such things.
So, that’s a lengthy post about a little script that brings me minor convenience. You could use this for launching all manner of applications, but I use it for game clients right now. Hopefully, it’s useful to you, too.