Pregunta

(OS: Windows 7)

Using SC.EXE I have created a Windows Service. Additionally, I created the necessary registry entries to specify the Application path (using key Parameters).

The "Application" is a .BAT file that sets several environment variables and then calls a Python script. When running the .BAT file directly from within CMD I get normal, desired behavior.

Using the Service Manager I can start and stop the service (works also with SC.EXE directly issued from CMD). All that is ok, no warning or errors or anything else to be seen (in Event Log).

The BAT file does not get executed. I double checked the Application path, double checked the service name.

  • Correction: The BAT file actually gets executed (created simple log file from within the BAT file). What does not work, apparently, is to execute the python.exe as the last command in the BAT file. I can't verify what error is generated by python.exe as I don't see any log files, event log entries...

BAT file contents:

@ECHO OFF
REM ==========================================================================
REM    ProcessIntergrationBridge Microsoft Windows Service Shell Script
REM ==========================================================================
SET CONSEQUOR_PIB_HOME=C:\opt\consequor\pib
SET CONSEQUOR_PIB_VERSION_DESIGNATOR=pib_b0100
SET CONSEQUOR_PIB_DATA=C:\var\opt\consequor\pib
SET CONSEQUOR_PIB_LOG=C:\var\opt\consequor\pib\log
SET CONSEQUOR_PIB_LOG_FILE=C:\var\opt\consequor\pib\log\pib.log
SET PYTHONPATH=C:\opt\consequor\pib\%CONSEQUOR_PIB_VERSION_DESIGNATOR%
SET PYTHONHOME=C:\opt\consequor\pib\python-runtime\win
SET PATH=%CONSEQUOR_PIB_HOME%\%CONSEQUOR_PIB_VERSION_DESIGNATOR%\bin;%CONSEQUOR_PIB_HOME%\python-runtime\win;CONSEQUOR_PIB_HOME%\python-runtime\win\DLLs;CONSEQUOR_PIB_HOME%\python-runtime\win\libs;CONSEQUOR_PIB_HOME%\python-runtime\win\Lib;%PATH%
SET CMD=%PYTHONHOME%\pythonw.exe %CONSEQUOR_PIB_HOME%\%CONSEQUOR_PIB_VERSION_DESIGNATOR%\%CONSEQUOR_PIB_VERSION_DESIGNATOR%\start_pib\pib_run_server.py debug
%CMD%

PIBD Service Registry entries: (Oh Merde Alors - I can't post pictures yet... - If someone wants to see then I can send via direct email ...)

PIBD Registry Entry

PIBD Parameters Setting

Thank you for any hint on how to debug this, fix it, change it - You know.

Kind regards

Frank - having spent days now trying to understand Windows mysteries.

¿Fue útil?

Solución 2

I recommend this approach:

  1. Start the command prompt in Session 0 as the System user
  2. Switch to Session 0 (either from the Interactive Services Detection dialog or from the command line) to find the command prompt
  3. Run the batch file from the command line and see what error it is reporting

But looking at the "SET PATH=" line, I see that some of the variables are not expressed properly (the leading % is missing on CONSEQUOR_PIB_HOME and others) which may be the issue...

Otros consejos

You should make sure that you actually call cmd.exe with your batch file as a argument instead of just calling the batch file.

Something similar to this:

C:\Windows\System32\cmd.exe /C C:\opt\consequor\pib\yourbatch.bat
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top