Using LPRUN from a Windows Service
Options
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
-
The docs (http://www.linqpad.net/lprun.aspx) state that:
> 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 -
I guess you'd have to check to see if it works *and* to see if it's covered under the license but if you reference the LinqPad executable you can use the Util (Util.Run, I believe) class to do things like compile queries and run them. Maybe this will get you past the lprun executable limitations?
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. -
Yes, using Util.Run from an external program is allowed under the license. This is also more efficient than starting a new process with LPRun.
Let us know if this works as expected.