I have the following code that runs a windows service from inside Java.The code uses JInterop Java library, JInterop is a pure Java COM client for windows COM server. More details of JIntop are available here [http://fishi.devtail.io/weblog/2015/01/21/pure-java-dcom-bridge-j-interop/]
String cmdFile = "service.bat";
results = wbemServices_dispatch.callMethodA(
"Get", new Object[]{ new JIString("Win32_Process"),
new Integer(0), JIVariant.OPTIONAL_PARAM()});
IJIDispatch wbemObjectSet_dispatch = (IJIDispatch)JIObjectFactory.narrowObject(
(results[0]).getObjectAsComObject());
results = wbemObjectSet_dispatch.callMethodA("Create",
new Object[]{ new JIString(targetFilePrefix + cmdFile),
JIVariant.OPTIONAL_PARAM(),
JIVariant.OPTIONAL_PARAM()});
Is it possible to run a powershell file(.ps1) as a service in the same manner as above using the same library, or in some other way.