Hello Luther,
First of all, please accept my apologies for the delayed reply.
Yes, the custom action does returns value 0 in the log, meaning that it executed successfully. However, it does not print something because the content of it is quite wrong.
First of all, in order to run a command line, "/c" or "/k" arguments must be used.
- /c argument will run the command and then will exit the command line
- /k argument will run the command and then will wait for an input from the user in order to exit
Additionally, have you tested the following command:
in a command line? Did it work?
I have downloaded and instlaled NSSM and the above command line did not work for any of my services. I had to give the full path to the NSSM executable.
Basically, here is a "semi-working" script:
Code: Select all
Function WriteToLog
Const MsgType = &H04000000
Set rec = Installer.CreateRecord(1)
Set ObjShell = Createobject("WScript.shell")
Set ObjExec = ObjShell.Exec("cmd.exe /c C:\Users\Catalin\Downloads\nssm-2.24\nssm-2.24\win64\nssm.exe status MyService")
dim strFromProc
strFromProc = ObjExec.StdOut.ReadAll
rec.StringData(1) = CStr("Personal Logs:")
rec.StringData(1) = CStr(strFromProc)
Session.Message MsgType, rec
WriteToLog = 0
End Function
This time, the event will be written in the log file. However, I noticed a problem for which I couldn't find any solution. In the log file, only the first letter of the output will be printed (which is "S" from "SERVICE_RUNNING" / "SERVICE_STOPPED").
I have tested this with a lot of other commands and everything worked as expected, except for this command.
In the above script, do not forget to replace the name with your Service name and also the path to your NSSM executable.
Hope this helps somehow.
Best regards,
Catalin
FOLLOW US
Get the latest news in Application Packaging