Using LPRUN from a Windows Service
I have some automation that runs as a Windows Service on a server, and I would like it to be able to run LinqPad scripts through LPRUN.
If I log in to the server using my service account, my LinqPad script works perfectly from the command line.
But if my Windows Service runs the LPRUN executable with the same parameters that work from the command line, the script never starts and LPRUN never returns.
I believe it is because LinqPad.exe is accessing something that requires a Windows session. Since my service doesn't have a session, this prevents it from running.
Has anyone successfully run LPRUN like this, without a Windows session? Is there a workaround? How large of a bribe would be necessary to get LPRUN to work without a session?
If I log in to the server using my service account, my LinqPad script works perfectly from the command line.
But if my Windows Service runs the LPRUN executable with the same parameters that work from the command line, the script never starts and LPRUN never returns.
I believe it is because LinqPad.exe is accessing something that requires a Windows session. Since my service doesn't have a session, this prevents it from running.
Has anyone successfully run LPRUN like this, without a Windows session? Is there a workaround? How large of a bribe would be necessary to get LPRUN to work without a session?
Comments
> NB: The command-line functionality is all inside LINQPad.exe. lprun.exe is merely a thin wrapper around LINQPad.exe that ensures proper Console behavior.
So it seems that it still functions as a desktop app that needs a Windows session.
Have you tried changing the LogOn Properties of your Windows Service, to enable "Allow service to interact with desktop", to see if that helps?
If you don't want to use the LocalSystem account, you could take a look at https://lostechies.com/keithdahlby/2011/08/13/allowing-a-windows-service-to-interact-with-desktop-without-localsystem/ and http://stackoverflow.com/questions/2345620/alternative-to-allow-service-to-interact-with-desktop
Disclaimer: I haven't tried it in a service but based on what I'm seeing, I think it's possible.
Additionally: I just checked the license and I don't see anything against using it this way.
Let us know if this works as expected.