如何从PERL脚本在Windows 7 64位创建的Windows服务 [英] How to Create Windows service from PERL script on Windows 7 64-bit

查看:385
本文介绍了如何从PERL脚本在Windows 7 64位创建的Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有任何人有一个如何在Windows上创建一个Windows服务的例子,从7 PERL脚本64位?

Does anybody have an example of how to create a windows service on windows 7 64-bit from PERL script?

在Windows XP专业版32位,我已经创建的窗口服务成功的Win32 ::守护进程有回调函数。这并不在64位工作。

On windows XP professional 32-bit, I have created windows service successfully with Win32::Daemon which has call back functions. This doesn't work on 64-bit.

我已经看到了这 http://nssm.cc/usage 并使用创建的服务,但它不'T保持状态,并给出了错误。如果有人有一个适当的例子也许...

I have seen this http://nssm.cc/usage and created a service using that but it doesn't keep state and it gives errors. If anybody has a proper example perhaps ...

一些想法多少AP preciated。

Some idea much appreciated.

推荐答案

我成功地解决了这个吧。

I managed to solved this now.

我现在有我的perl脚本运行作为Windows服务,现在在Windows 7 64位。

I now have my perl script running as a windows service now on windows 7 64-bit.

的win32基本上::守护程序的工作在Win 7 64位,但服务的创建需要手动完成。即回调函数并启动的罚款。

Basically win32::Daemon works on win 7 64-bit but the service creation needs to be done manually. I.e. the callback functions and start up is fine.

下面是一个例子从头开始创建perl的Windows服务。

Here is a example to create perl windows service from scratch.

  1. 创建文件夹C:/为MyService

  1. Create folder c:/myservice

复制此链接code为例,并将其保存到上面的目录。 myservice.pl( http://www.roth.net/forums/topic说它的.php?ID = 106

Copy the code example from this link and save it to the directory above. Call it myservice.pl (http://www.roth.net/forums/topic.php?id=106)

在脚本中的打印问候语句后添加下面两行。

Add these two lines after the print hello statement in the script.

$上下文> {last_state} = SERVICE_RUNNING;

的Win32 ::守护::国家(SERVICE_RUNNING);

这是需要保持业务正常运行。否则,它会停止。

This is needed to keep the service running. Otherwise it stops.

中打开管理模式一个Dos CMD终端。使用以下命令创建服务

Open a Dos cmd terminal in admin mode. Create service using following command

%SC创建的MyService binpath =C:\草莓\ perl的\斌\ perl.exe所在

它会显示以下成功的消息。 [SC] CreateService函数成功

It will display following message on success. [SC] CreateService SUCCESS

  1. 现在我们需要编辑注册表。打开注册表编辑器。 (开始 - >然后键入regedit)

  1. Now we need to edit the registry. Open registry editor. (start -> then type regedit)

查找下HKEY_LOCAL_MACHINE->系统 - > CurrentControlSet->服务 - >为MyService服务

Find the service under HKEY_LOCAL_MACHINE->SYSTEM->CurrentControlSet->Services->myservice

点击为MyService和编辑的ImagePath变量是: C:\草莓\ perl的\斌\ perl.exe所在-IC:\为MyServiceC:\为MyService \ myservice.pl--run

Click on 'myservice' and edit the imagePath variable to be : c:\strawberry\perl\bin\perl.exe -I "C:\myservice" "C:\myservice\myservice.pl" --run

现在打开服务窗口,并启动服务。 (开始 - >控制面板 - >管理工具 - >服务)

Now open the services window and start the service. (start->control panel -> Administrative tools -> services)

在脚本的当前目录中的日志创建和更新每两秒钟。如果使用的cygwin的Windows,您可以尾巴吧。

In the current directory of the script a log is created and updated every couple of seconds. If using cygwin for windows, you can tail it.

%尾-f * .log文件

工艺将打印你好!定期...

Process will print Hello! periodically ...

感谢。

这篇关于如何从PERL脚本在Windows 7 64位创建的Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆