Running a command prompt as the LocalSystem account
Often when working with Windows services, I've wanted to have the ability to log in as the LocalSystem user in order to try to diagnose problems. For example, one recent problem that I was experiencing is on ccnetlive we run CruiseControl.NET as a Windows service under the LocalSystem account. The problem was that when accessing a Subversion repository over SSL, you are required to accept the certificate from the remote host. Accepting the certificate requires responding to a command-line prompt. Once accepted, this certificate can then be cached permanently, so it is not necessary to re-accept the certificate -- at least until it expires. Unfortunately, there is no way to log in directly as the LocalSystem user -- so the runas command will not work. In trying to find a solution to this problem, I came across a very useful blog post that describes creating a Windows service that simply opens a new command shell. As Windows services, by default, run under the LocalSystem account, this command shell window is open under the LocalSystem account.