PDA

View Full Version : Question about Create Service



NewsArchive
04-26-2013, 12:26 AM
Hi Friedrich,

I have a question about the Create Service function:
In the field "Executable Path", can I also execute a batch (.BAT) file?

I know a free tool (NSSM) which can also handle batch files:
http://nssm.cc/scenarios

--
Best regards,
Jeffrey

NewsArchive
04-26-2013, 12:26 AM
Hi Jeffrey,

> I have a question about the Create Service function:
> In the field "Executable Path", can I also execute a batch (.BAT)
> file?
>
> I know a free tool (NSSM) which can also handle batch files:
> http://nssm.cc/scenarios

The Create Service function creates a service object and adds it to the
specified service control manager database. It has nothing to do with batch
files!

"Executable Path" contains the fully qualified path to the service binary
file. In other words, you have to specify the service file here (e.g.
c:\test\myservice.exe)

A batch file is not a service. Of course, you can handle batch file from
Windows applications (no need to use NSSM). To "run" a batch file, you must
start the command interpreter (cmd.exe).

Something like:

cmd /C c:\mydir\MyBatch.bat

in a "Run Command Line..." or "Run Program..." function.

Does this help?

Friedrich

NewsArchive
04-26-2013, 12:26 AM
Hi Friedrich,

Let me explain:

I want to create a service, it's a NetTalk WebServer application.
With NSSM I can specify as service file a batch file which I need.
The problem for me is that my application has to point to the directory
where my DATA files are (tps files).
My application is installed in C:\Company\Program\myprogram.exe
My data files (*.tps) are installed in C:\Company\Data
So I can create a batch file startup.bat with:

cd /d C:\Company\Data
C:\Company\Program\myprogram.exe

With NSSM I can install a service "MyService" which points to
startup.bat which works in my situation.
But of course I would like to use SB to create a service.
So the question stands:
Can I use startup.bat in the field "Executable Path"?

Best regards
Jeffrey

NewsArchive
04-26-2013, 12:26 AM
Jeffrey,

> cd /d C:\Company\Data
> C:\Company\Program\myprogram.exe

Wouldn't it be cleaner to store the data path in an INI file or
registry entry and let the EXE use SYSTEM{PROP:DataPath}?

--
Lee White

RPM Report Viewer.: http://www.cwaddons.com/products/rpm/
RPM Review........: http://www.clarionmag.com/cmag/v11/v11n06rpm.html
Report Faxing.....: http://www.cwaddons.com/products/afe/
---Enroll Today---: http://CWaddons.com

Enhanced Reporting: http://CreativeReporting.com

Product Release & Update Notices
http://twitter.com/DeveloperPLUS

Windows 8 brings us "The Oval, Bumper Car, Roller Coaster of Wait!"

NewsArchive
04-26-2013, 12:27 AM
Hi Lee,

Yes, I agree but at this moment I can't change it and have to deal with
the current situation. ;-)

Best regards,
Jeffrey

NewsArchive
04-26-2013, 12:27 AM
Jeffrey,

> Yes, I agree but at this moment I can't change it and have to deal with
> the current situation. ;-)

In that case I'd recommend a very small Clarion EXE that handles this
for you, as opposed to a batch file, and RUN()'s your secondary EXE.

PROGRAM
MAP END

CODE
SetPath('C:\Company\Data')
RUN('C:\Company\Program\myprogram.exe')
RETURN


You could even create the equivalent in an SB install.

--
Lee White

RPM Report Viewer.: http://www.cwaddons.com/products/rpm/
RPM Review........: http://www.clarionmag.com/cmag/v11/v11n06rpm.html
Report Faxing.....: http://www.cwaddons.com/products/afe/
---Enroll Today---: http://CWaddons.com

Enhanced Reporting: http://CreativeReporting.com

Product Release & Update Notices
http://twitter.com/DeveloperPLUS

Windows 8 brings us "The Oval, Bumper Car, Roller Coaster of Wait!"

NewsArchive
04-26-2013, 12:28 AM
> You could even create the equivalent in an SB install.

Run Program C:\Company\Program\myprogram.exe (Always Install)

--
Lee White

RPM Report Viewer.: http://www.cwaddons.com/products/rpm/
RPM Review........: http://www.clarionmag.com/cmag/v11/v11n06rpm.html
Report Faxing.....: http://www.cwaddons.com/products/afe/
---Enroll Today---: http://CWaddons.com

Enhanced Reporting: http://CreativeReporting.com

Product Release & Update Notices
http://twitter.com/DeveloperPLUS

Windows 8 brings us "The Oval, Bumper Car, Roller Coaster of Wait!"

NewsArchive
04-26-2013, 12:28 AM
Thanks Lee, great tip!

Best regards,
Jeffrey

NewsArchive
04-26-2013, 12:29 AM
Jeffrey,

> Thanks Lee, great tip!

Since this is supposed to run as a service you might need to use the
WAIT option whether it's an SB script or a Clarion EXE that's loading
your root program.

--
Lee White

RPM Report Viewer.: http://www.cwaddons.com/products/rpm/
RPM Review........: http://www.clarionmag.com/cmag/v11/v11n06rpm.html
Report Faxing.....: http://www.cwaddons.com/products/afe/
---Enroll Today---: http://CWaddons.com

Enhanced Reporting: http://CreativeReporting.com

Product Release & Update Notices
http://twitter.com/DeveloperPLUS

Windows 8 brings us "The Oval, Bumper Car, Roller Coaster of Wait!"

NewsArchive
04-26-2013, 12:30 AM
Thanks!

Best regards,
Jeffrey Kuijt