Archive for May, 2007

Making Baldur’s Gate II run in a non-admin account on Windows

Saturday, May 26th, 2007

Today I had the fun experience of dealing with Windows, and the also-fun experience of dealing with poorly-written Windows programs.

The reason for this, and the reason I didn’t just say “not my problem” and give up, was that I wanted to play Baldur’s Gate II. Specifically, I wanted to play it multiplayer, and my dad only lets my siblings use his computer under a limited account (the right thing to do), so I had to find a way to make it play. Installing could be done under an admin account, of course, but playing had to be done under a limited.

This is where the poorly-written bit became a problem. You see, Baldur’s Gate II, like about 97% of windows programs, violates the standards of what things go where in windows. This of course was not a surprise to me, just an annoyance. So I was determined to find a way around it.

The first, most obvious problem, was that it needed to write to files in the program files directory (like, e.g., save files. They’re not supposed to go there! They’re supposed to go in the Application Data folder in the user’s account! I’m not even a windows developer user and I know that!), which limited accounts aren’t allowed to do. Easy fix: Change the permissions on all those files to let anyone write to them. Roadblock to the easy fix: XP home doesn’t have the advanced security tab that lets you control the access control lists. Doh. So with about 10 minutes searching online, I finally found out about the cacls command, which can be run from the command line even in home edition. I got the funness of finding out by trial and error that without the /E switch, it will remove the entire list when you do /P, even though it says it’ll “replace the user’s” permissions. Luckily I’d listed them all out before and still had them on screen. Final command for that: cd installdir; cacls "BGII - SoA" /T /E /P Users:F

Then, it still didn’t run. When you started up the game in the limited account, it still, for some reason, thought it needed to be installed. I had thought (from reading support things on the official website) that making baldur.ini writable would fix that, but I was wrong. So: It must be a registry issue. Long story short, because I’m getting tired of writing about Windows: It was. /HKLM/SOFTWARE/Microsoft/Currentversion/App Paths/BG2Main.exe was readable by the limited user, but apparently, no, it needed to be writable as well, because the programmers were stupid and used the wrong registry call. (Thanks to regmon for helping me find that out). Fix: go in as admin, right click on that key, and there’s some properties that let you make it writable by all. Problem fixed, everything works now.

This all is just one of the many reasons I hate windows.

piping standard error

Wednesday, May 16th, 2007

I’ve often wished I could pipe only standard error to a command, leaving standard out to display on the screen as is. One place this would be useful, the one that finally got me to act, is to make compiler warnings show up in a different color, to make them more noticeable.

I decided grep ".*" would work quite well for coloring things, since I have --color=AUTO on by default. The problem, though, was how could I get standard error to go to grep instead of standard out? (I have green text on a black background, and grep turns what it matches red. If I piped standard out to grep ".*", I’d get red text with green errors, and that’s just backwards :P)

The internet wasn’t very helpful. It gave me a bunch of things halfway there, like redirecting standard error to standard out, and even saving standard out as a file and redirecting standard error to standard out and piping that, but I wanted standard error to stay standard error, standard out to stay standard out, and them both displayed on screen like normal, only with stderr having been run through a command.

So, of course, I had to do it myself.

Here’s what I came up with: (command 2>&1 1>&3 | grep ".*" 1>&2) 3>&1

So how’s this work? Well, first stdout (file handle 1) is redirected to file handle 3. Yes, that’s first. Apparently they’re evaluated in backwards order. Took me a while to figure that out. Then stderr (file handle 2) is redirected to stdout (file handle 1). Then it’s piped to grep (or whatever command you want, I could see useful things being done with sed here) and the output sent back to stderr, and then finally file handle 3, the original stdout, is sent back to stdout.

I hope someone finds this useful. I know I will!

Sentences

Wednesday, May 9th, 2007

Dear internets:

Is it possible to make a sentence using only onomatopoeia?

Thank you,

–dolphinling

Linux TP down 10%!

Wednesday, May 9th, 2007

Thank you, bug 375760:

And a big thank you to roc for writing that patch, and vlad for reviewing it too!