【问题标题】:Quartz.NET : running PHP cmd line results in ACCESS DENIED on php_mssql.dll?Quartz.NET:运行 PHP cmd 行会导致 php_mssql.dll 上的访问被拒绝?
【发布时间】:2010-12-01 17:31:24
【问题描述】:

我有一个实现 Quartz.NET 调度的 Windows 服务,它从 XML 文件中读取计划的作业信息,解析它以运行 cmd 行,并使用解析的参数创建一个计划的作业。

我目前正在使用 PHP 命令行脚本来测试调度程序的命令行执行,它似乎可以很好地启动作业,并且它们甚至成功完成,在 eventLog 中显示脚本输出...

问题是每次运行时,都会显示一个带有错误的警告弹出窗口:

“PHP 启动:无法加载动态库 'C:\php5\php_mssql.dll' - 访问被拒绝”

如果我对这个警告响应 OK,脚本似乎运行良好,但如果它仍然在屏幕上,进一步计划的 PHP 脚本将运行到完成,但输出为空(我假设之前运行的暂停作业阻止了给它。)...

如何以编程方式阻止访问被拒绝消息?

运行解析后的CMD行的Quartz.NET Job Execution脚本如下:

public void Execute(JobExecutionContext context)
    {
        EventLog eventLog = new EventLog();
        eventLog.Source = "SchedulerServiceSource";
        eventLog.Log = "SchedulerService";


        JobDataMap dataMap = context.MergedJobDataMap;  // contanis information for this job parsed from the XML file.
        String jobName = dataMap.GetString("name");
        String execute = dataMap.GetString("execute");
        String args = dataMap.GetString("arguments");

        //String LogMsg = "JobRunner Executing=============\n"; // Written to event log after job execution
        //LogMsg += "JobName: " + jobName + "\n";
        //LogMsg += "Executing: " + execute + "\n";
        // eventLog.WriteEntry(LogMsg); // Write the job's details to the log

        try
        {
            Process p = new Process(); // Start the child process.
            // Redirect the output stream of the child process.
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.FileName = execute;
            p.StartInfo.Arguments = args;
            p.Start();
            // Do not wait for the child process to exit before
            // reading to the end of its redirected stream.
            // p.WaitForExit();
            // Read the output stream first and then wait.
            String output = p.StandardOutput.ReadToEnd();
            p.WaitForExit();
            eventLog.WriteEntry(jobName + "\nexecuted:\n---------------\n" + execute + " " + args + "\n---------------\nRESULTS:\n===============\n" + output + "\n===============");
        }
        catch (Exception ex)
        {
            eventLog.WriteEntry(jobName + "\nattempted to execute:\n---------------\n" + execute + " " + args + "\n---------------\n...FAILED:\n===============\n" + ex.Message + "\n===============", EventLogEntryType.Error);
        }
    }

提前谢谢大家!

编辑:我正在运行的 php 脚本是一个简单的 HELLO WORLD,它不与数据库交互,但我有一种感觉,如果我确实运行了一个使用 DB 功能的脚本,它会由于拒绝访问消息而失败。 ..这也是不能接受的,这个项目我必须能满负荷使用PHP!

EDIT2:我使用 Windows LocalService 帐户安装了该服务。

【问题讨论】:

    标签: php sql-server quartz.net


    【解决方案1】:

    试试这个(从另一个网站的论坛复制)

    将以下文件复制到 System32 目录下 1. libmysql.dll 2.msql.dll

    将以下文件复制到php\ext目录下 1. msql.dll 。解压 PHP 5 zip 文件时应该复制此文件,但显然不是

    重启网络服务器

    【讨论】:

    • 这将需要我更改安装此 Windows 服务的服务器上的文件配置,而在运行此调度程序服务的生产环境中我可能无法做到这一点...是否可以向进程添加任何路径以允许这样做?
    【解决方案2】:

    事实证明,以 LOCALSYSTEM 身份运行服务可以解决此问题...

    【讨论】:

      猜你喜欢
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-22
      • 1970-01-01
      • 2011-08-09
      相关资源
      最近更新 更多