Tuesday, January 29, 2008

Selectively Start and Stop Services with sc.exe and AutoHotkey

I recently got a copy of Corel Painter X and noticed that after installing, there was a new Windows service that kept starting up called ProtexisLicensing. Looking online confirmed that it was required to validate your copy of Painter. The problem is Painter needs to be validated by ProtexisLicensing every time it starts up, and if ProtexisLicensing isn't running when you start up Painter, Painter won't load up at all.

I don't use Painter enough to be fine with this background process taking up several megabytes to load every time I start Windows. Luckily, with the help of a utility called sc.exe and Autohotkey, we can tweak the Painter shortcut to start up Protexis Licensing before running Painter, and then turning it off when Painter is closed.

First, download sc.exe . I can't find a specific download location right now, but just google for it and you should find it eventually. It's a Service Controller that lets you start and stop your installed Windows services, among other useful features that I haven't gotten to learn about yet.

Next, create an autohotkey script. Mine is called painter.ahk. The code looks like this:

Run C:\Documents and Settings\Arvin\My Documents\scripts\sc.exe start ProtexisLicensing

Sleep, 1000

Runwait C:\Program Files\Corel\Corel Painter X\Painter X.exe

Run C:\Documents and Settings\Arvin\My Documents\scripts\sc.exe stop ProtexisLicensing
The paths of these files might differ depending on where you put your downloaded sc.exe and installed Painter, so alter as necessary.

What this script does is calls sc.exe to first start the Windows service ProtexisLicensing. Then it waits 1000 ms (1 second), and then runs Painter. RunWait is a command that basically means "run, then pause the script until such and such file is closed." So once Painter is shut down, it runs the next line, which stops ProtexisLicensing.

Then, you can change your start menu or Desktop shortcut for Painter to point to this script instead of running Painter X.exe.

To do this right click on the shortcut, and click Properties. Then change the target to point to the new Autohotkey file. Change "start in" to the folder in which the script is located.

Likely once you fix this the icon will change to the Autohotkey icon. To change this, go to the properties of the shortcut again and hit "Change icon." Then go to to location of the installed Painter.exe file and select it, with its proper icon.

Finally, hit Windows>run>services.msc to load the Services control window. Find the ProtexisLicensing service and set it to disabled (you can also stop it right then). From here on out ProtexisLicensing will no longer run at startup, or ever with the exception of when you call it.

And that's it! Save yourself some RAM space!

Of course, you can use sc.exe and Autohotkey to do this for any other Windows service you have that doesn't need to run every time. Just be sure you know exactly what those particular services affect. For more information, see how I took command of my Windows services.

Related Posts by Categories

Widget by Hoctro | Jack Book


Martin-S said...

Nice article. Helped me out quite a bit :)

Thought you might want to know I found a download location for sc.exe


Michael said...

I have the same problem but I haven't even installed it yet. Any way to fix that too?

R' Russell said...

I found that SC.exe is already installed on XP systems in C:\Windows\System32\SC.EXE