Jump to content
Sign in to follow this  
sulfurious

Run as Service/ Create Service

Recommended Posts

sulfurious

Hi.

I have been attempting to create a service that continues to run during logoff. Specifically, I am wanting to turn the monitor off after a logoff, because a friend has a computer that does not behave properly with power saving features like turning the monitor off after 10 minutes etc.

I am working on a simple script that turns his monitor off, then after x mintues of inactivity, logs off. Both portions work. but the logoff terminates the service, which runs under local system.

I have been using the method described here to create and start/stop the service

services udf

which is included in the FAQ in this forum.

This does create a service, but must be under the wrong context.

Ptrex made a gui for adding a service using WMI Win32_BaseService class, that utilizes Srvany.exe. Found here

ptrex au3 service

this does work. A logoff still allows the script to remain running.

I am wondering, after looking at msdn, if it is even possible without the help of srvany.exe, to create a service that does what I want. I have plugged in different settings such as using the NT_Authority/network service, stuff like that. Tried using interactive/non interactive settings.

I can certainly use srvany.exe, but like most, would prefer to figure out how to do this without it. Here is a piece I have been tring to call with, using the ServiceControl udf.

_CreateService("", $sServicename, "Test_Service", "C:\windows\system32\srvany.exe", "NT AUTHORITY\LocalService", "", 0x110)
;~  _CreateService("", $sServicename, "Test_Service", "C:\windows\system32\srvany.exe", "LocalSystem", "", 0x110)
RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\" & $sServicename & "\Parameters", "Application", "REG_SZ", @ScriptFullPath)

Nothing else in the script that is out of the ordinary. Nothing GUI except the tray icon, which will probably be hidden. Simple command line to install/uninstall the service, and a check for if the service not running to run it.

Does anyone know why this would be happening, and what parameter I must pass to the CreateService to achieve the desired effect?

Sul.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×