インストール方法、プログラムとしてのサービスが自動起動し、起動中の?

StackOverflow https://stackoverflow.com/questions/2146204

  •  23-09-2019
  •  | 
  •  

質問

ったものPHPスクリプトを実行してサービスです。

やめるのか?

役に立ちましたか?

解決

あなたはSC.EXEを使用する必要があります。詳細については、 http://support.microsoft.com/kb/251192 に訪問。  それからちょうど

を実行するためのサービスのためのコマンドラインとしてphp.exeにyourscriptnameを使用

他のヒント

あなたは少しCSHARPで手の汚れを取得してもかまわない場合は、ここではWindowsサービスであるシェルアプリケーションでのURLです。それは(すなわち、スクリプト)秒数ごとにバッチファイルを実行し、タイマーを設定します。スクリプトは、その後、終了したタスクを実行している場合にのみ動作します。 (これは私のコードではありませんので、コミュニティのwikiとしてマーク。私はリンクサイトは、将来的に死んで行く場合には、ここですべてのコードをコピーしています。)

ます。http://www.akchauhan。 COM /作成-Windowsのサービス・ツー・スケジュールのphpスクリプト実行/

ここではリンク先の記事に記載されたコードがあります。

C#のサービスのために:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Timers;

namespace MyNewService
{
    public partial class MyNewService : ServiceBase
    {
        private Timer syncTimer = null;  

        public MyNewService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            syncTimer = new Timer();
            this.syncTimer.Interval = 180000;
            this.syncTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.syncTimer_Tick);
            syncTimer.Enabled = true;
        }

        protected override void OnStop()
        {
            syncTimer.Enabled = false;
        }

        private void syncTimer_Tick(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start(@"C:\xampp\htdocs\task.bat");
        }  
    }
}

必要なバッチファイルます:

@echo off  
cd\  
set path=C:\xampp\php;  
cd "C:\xampp\htdocs"  
php import.php  
exit  

これは可能性がある質問 https://superuser.com/ または https://serverfault.com/

この手伝いはサービスに関するご質問 http://support.microsoft.com/kb/251192

微力ですが、応援させていただきていたwindowsで入手できるかもしれませんが、できる設定バッチファイルとしてサービスです。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top