0

I have exposed SGW_HOME variable on windows nanoserver and trying to use it in the xml file

<service>

  <!-- ID of the service. It should be unique across the Windows system-->
  <id>SGWJavaService</id>
  <name>SGWJavaService</name>
  <description>SGW Java service</description>
  <env name="SGW_HOME" value="%SGW_HOME%"/>
  <!-- Path to the executable, which should be started -->
  <!-- CAUTION: Don't put arguments here. Use <arguments> instead. -->
  <executable>java</executable>
  <arguments>-jar %SGW_HOME%\\lib\\mgmt-node-1.0.0.jar</arguments>
</service>

I can create service with command

WinSW-x64.exe install sgw.xml

but service failed to start

C:\program-files>sc query SGWJavaService

SERVICE_NAME: SGWJavaService
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 1067  (0x42b)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

C:\program-files>

How do I use env variable into xml file?

Ganesh Shinde
  • 65
  • 2
  • 7
  • Are you aware that on some platforms the java command has a flag -d32 or -d64 . Aside that, in Windows, there is a console on the start menu for running services. It may been installed but I don't see any command to start it. Type "services" into the start menu search bar. – Samuel Marchant Feb 27 '23 at 13:24
  • I am running this in a nanoserver container, there is no UI. anyway I have found a workaround, can use %BASE% to get to jar file. – Ganesh Shinde Feb 27 '23 at 16:04

1 Answers1

0

java -jar myjar.jar "."

  • Add "." if the .properties file is in the same folder as WinSW-x64.exe or else specify the path of your config file in the quotation marks
  • Specify the command in the "arguments" tag