6 Version 0.0, first alpha, 10th June 2002 by Ximon Eighteen.
7 Version 0.1, added GetServiceNameFromDisplayName(), 5th June 2003 by Ximon Eighteen.
10 What The Hell Is This?
11 ----------------------
13 If you've ever had to make an installation program that had to start, stop,
14 remove or otherwise manipulate a Windows NT Service then you'll find this
15 useful. It's a collection of functions that can be used from an NSIS script
16 (Nullsoft Installation System, http://www.nullsoft.com/free/nsis) to manipulate
17 Windows NT (and hopefully 2000 and XP) Services.
19 If you don't know what I'm talking about then you don't need this, simple.
21 Most of the code is based on information found in the Microsoft Knowledge Base
22 and the MSDN Platform SDK documentation.
24 I haven't released anything in quite a long time so if I've forgotten something
25 or have generally fouled up somewhere then for gods sake tell me.
27 Feel free to send comments/suggestions/bug fixes/hate mail/biscuits to
28 ximon_eighteen@3b2.com.
30 As long as you don't violate any nullsoft agreement that might be binding on
31 an extension DLL for their NSIS product as far as I'm concerned you can do
32 absolutely anything with this code, claim as your own if you like although
33 that would be a bit low.
35 I'll answer any questions that I can, but I'm not responsible if this fouls
36 up your system, use this at your own risk. If something does go wrong I'll do
37 what I can to help, but I think this is highly unlikely ;-)
41 Ximon Eighteen aka Sunjammer
53 - sendservicecommand.c
56 - Visual C++ 6.0 project file (.dsp) [ release & debug configurations ]
57 - Services.nsi [ example ]
58 - FindService.nsi [ example ]
60 The code is based on the exdll project that shipped with 0.98 of the NSIS
61 distro. Building the project should result in a .dll file that you can then
62 use with the CallInstDLL NSIS scripting command.
68 - I don't think the SendServiceCommand should really support a delete
69 option, perhaps it should be a separate function?
70 - No other known issues.
73 Function Level Docs : [ extracted from the source ]
76 GetServiceNameFromDisplayName:
77 DESC: Find the internal service name of all services whose display name (as
78 DESC: seen in the Services Control Panel) contains the given name or name
79 DESC: fragment (case insensitive match).
80 ARGS: Push the display name or display name fragment onto the stack
81 RETN: One or more values on the stack.
82 RETN: The first will be the count of matches found.
83 RETN: The second will be the reason for finding no matches, OR the first match.
84 RETN: The third and so on will be the remaining matches upto the count.
85 USGE: See the FindServices.nsi example.
87 IsProcessUserAdministrator:
88 DESC: Find out if the user (the owner of the current process) is a member of
89 DESC: the administrators group on the local computer (not on the domain!).
90 ARGS: Push the service name onto the stack.
91 RETN: Pop the result string from the stack.
92 RETN: The result will be 'Yes' or 'No' if there were no problems, otherwise
93 RETN: the reason for the failure will be in the result string.
94 USGE: Use it like this :-
96 USGE: services::IsProcessUserAdministrator
98 USGE: ; $0 now contains either 'Yes', 'No' or an error description
101 DESC: Find out if the current user (the owner of the process) has the LSA
102 DESC: (Local Security Authority) policy right 'SeServiceLogonRight'.
103 RETN: Pop the result string from the stack.
104 RETN: The result will be 'Yes' or 'No' if there were no problems, otherwise
105 RETN: the reason for the failure will be in the result string.
106 USGE: Use it like this :-
108 USGE: services::HasLogonAsAService '3B2\Ximon_Eighteen'
110 USGE: ; $0 now contains either 'Yes', 'No' or an error description
112 GrantLogonAsAService:
113 DESC: Grant the current user (the owner of the process) the LSA
114 DESC: (Local Security Authority) policy right 'SeServiceLogonRight'.
115 RETN: Pop the result string from the stack.
116 RETN: The result will be 'Ok' if there were no problems, otherwise
117 RETN: the reason for the failure will be in the result string.
118 USGE: Use it like this :-
120 USGE: services::GrantLogonAsAService '3B2\Ximon_Eighteen'
122 USGE: ; $0 now contains either 'Yes', 'No' or an error description
124 RemoveLogonAsAService:
125 DESC: Deny the current user (the owner of the process) the LSA
126 DESC: (Local Security Authority) policy right 'SeServiceLogonRight'.
127 RETN: Pop the result string from the stack.
128 RETN: The result will be 'Ok' if there were no problems, otherwise
129 RETN: the reason for the failure will be in the result string.
130 USGE: Use it like this :-
132 USGE: services::RemoveLogonAsAService '3B2\Ximon_Eighteen'
134 USGE: ; $0 now contains either 'Yes', 'No' or an error description
137 DESC: Find out if the named service is installed.
138 ARGS: Push the service name onto the stack.
139 RETN: Pop the result string from the stack.
140 RETN: The result will be 'Yes' or 'No' if there were no problems, otherwise
141 RETN: the reason for the failure will be in the result string.
142 USGE: Use it like this :-
144 USGE: services::IsServiceInstalled 'MyServiceName'
146 USGE: ; $0 now contains either 'Yes', 'No' or an error description
149 DESC: Find out if the named service is installed and running.
150 ARGS: Push the service name onto the stack.
151 RETN: Pop the result string from the stack.
152 RETN: The result will be 'Yes' or 'No' if there were no problems, otherwise
153 RETN: the reason for the failure will be in the result string.
154 USGE: Use it like this :-
156 USGE: services::IsServiceRunning 'MyServiceName'
158 USGE: ; $0 now contains either 'Yes', 'No' or an error description
161 DESC: Send a command (Start, Stop, Pause, Continue or Delete) to the Service
162 DESC: Control Manager (SCM) for a given service.
163 ARGS: Push service command string onto the stack
164 ARGS: Push service name string onto the stack
165 RETN: Pop the result string from the stack.
166 RETN: The result will be 'Ok' if there were no problems, or the reason for
167 RETN: failure otherwise.
168 USGE: Use it like this :-
170 USGE: services::SendServiceCommand 'start' 'MyServiceName'
172 USGE: StrCmp $0 'Ok' success 0
173 USGE: MessageBox MB_OK|MB_ICONSTOP 'Failed to send service command: Reason: $0' 0 0