On top of that, if you’re running Win7, and right click on a .bat file and choose to “run as Administrator”, the current working directory does not get set to the folder where the .bat is located. What a pain.

Instead of building an SOE as a dll, build it as an exe. The Main program of the SOE can do the registration/unregistration. First, by calling Regasm, and then by registering with AGS, similar to Esri’s sample.

I haven’t tested this a lot in production, so if you run into issues, please let me know.