ServiceLib appears to have a bug...
Not sure whether this is the right forum, sorry if it is not.
I have been trying to register a service to run as a particular user, and noticed that the ServiceLib code is not passing a "t" for the last three arguments to CreateServiceA.
I changed the code (see below for an example... I can provide the complete file if needed), and now it works fine. Who would be in charge of updating the code on the web site (if it is deemed correct)? I tried to find a way to contact the original author of that code, but couldn't...
Also... the example page at http://nsis.sourceforge.net/archive/...php?pageid=345 should probably mention that the arguments passed to the call need to end with a ";" (I ran into that issue as well).
Finally, as far as I can tell, the "machine" argument should be called more something like "dependencies" (at least according to the MS docs).
Well this is reall the last question... I noticed a stalled thread on finding a way to programatically change the "log on as a service" setting for an account... is there any conclusion/solution for that?
The new code (just replace the relevant old code):
; create service
lbl_create:
Push $R1 ;depend
Push $R2 ;user
Push $R3 ;password
Push $R4 ;interact
Push $R5 ;autostart
Push $R6 ;path
!insertmacro CALL_GETPARAM $R1 "depend" "n" "lbl_depend"
lbl_depend:
StrCmp $R1 "n" lbl_depend_null lbl_depend_not_null
lbl_depend_null:
StrCpy $R7 ""
Goto lbl_depend_done
lbl_depend_not_null:
StrCpy $R7 "t"
lbl_depend_done:
!insertmacro CALL_GETPARAM $R2 "user" "n" "lbl_user"
lbl_user:
StrCmp $R2 "n" lbl_user_null lbl_user_not_null
lbl_user_null:
StrCpy $R8 ""
Goto lbl_user_done
lbl_user_not_null:
StrCpy $R8 "t"
lbl_user_done:
!insertmacro CALL_GETPARAM $R3 "password" "n" "lbl_password"
lbl_password:
StrCmp $R3 "n" lbl_password_null lbl_password_not_null
lbl_password_null:
StrCpy $R9 ""
Goto lbl_password_done
lbl_password_not_null:
StrCpy $R9 "t"
lbl_password_done:
!insertmacro CALL_GETPARAM $R4 "interact" "0x10" "lbl_interact"
StrCpy $6 0x10
IntCmp $R4 0 +2
IntOp $R4 $6 | 0x100
StrCpy $R4 $6
lbl_interact:
!insertmacro CALL_GETPARAM $R5 "autostart" "0x3" "lbl_autostart"
StrCpy $6 0x3
IntCmp $R5 0 +2
StrCpy $6 0x2
StrCpy $R5 $6
lbl_autostart:
!insertmacro CALL_GETPARAM $R6 "path" "n" "lbl_path"
lbl_path:
StrCmp $R6 "n" lbl_path_null lbl_path_not_null
lbl_path_null:
StrCpy $R0 ""
Goto lbl_path_done
lbl_path_not_null:
StrCpy $R0 "t"
lbl_path_done:
System::Call 'advapi32::CreateServiceA(i r4, t r2, t r2, i ${SERVICE_ALL_ACCESS}, i R4, i R5, i 0, $R0 R6, n, n, $R7 R1, $R8 R2, $R9 R3) i.r6'
Thanks,
Sven