douao2019 2010-12-01 17:31
浏览 53
已采纳

Quartz.NET:运行PHP cmd行导致php_mssql.dll上的ACCESS DENIED?

I have a Windows Service implementing Quartz.NET scheduling which reads scheduled job information from an XML file, parses it for a cmd line to run, and creates a scheduled job with the parsed parameters.

I'm currently using PHP command line scripts to test the command line execution of the scheduler, and it seems to be kicking off jobs just fine, and they even complete successfully, showing the script output in the eventLog...

The problem is every time it runs, a Warning popup displays with the error:

"PHP Startup: Unable to load dynamic library 'C:\php5\php_mssql.dll' - Access is denied"

If I respond OK to this warning, the script seems to run fine, but if it remains on screen, further scheduled PHP scripts will run to completion, but the output is empty (I assume held up by the paused job running prior to it.)...

How can I prevent that access denied message programmatically?

The Quartz.NET Job Execution script that runs the parsed CMD line is as follows:

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=============
"; // Written to event log after job execution
        //LogMsg += "JobName: " + jobName + "
";
        //LogMsg += "Executing: " + execute + "
";
        // 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 + "
executed:
---------------
" + execute + " " + args + "
---------------
RESULTS:
===============
" + output + "
===============");
        }
        catch (Exception ex)
        {
            eventLog.WriteEntry(jobName + "
attempted to execute:
---------------
" + execute + " " + args + "
---------------
...FAILED:
===============
" + ex.Message + "
===============", EventLogEntryType.Error);
        }
    }

Thanks everyone in advance!

EDIT: The php script I'm running is a simple HELLO WORLD which does NOT interact with the Database, but I have a feeling if I DID run one that used DB functionality, it would fail due to the Access Denied msg... This is also unacceptable, and I must be able to use PHP in full capacity for this project!

EDIT2: I have the service installed using a Windows LocalService account.

  • 写回答

2条回答 默认 最新

  • duanniying2342 2010-12-01 20:57
    关注

    Turns out that running the service as LOCALSYSTEM fixes this problem...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 QQ邮箱过期怎么恢复?
  • ¥15 (标签-android|关键词-app)
  • ¥15 微信小程序web-view嵌套H5页面IOS左滑会出现相同的页面,有什么解决方法吗?
  • ¥60 如何批量获取json的url
  • ¥15 comsol仿真压阻传感器
  • ¥15 Python线性规划函数optimize.linprog求解为整数
  • ¥15 llama3中文版微调
  • ¥15 pg数据库导入数据序列重复
  • ¥15 三分类机器学习模型可视化分析
  • ¥15 本地测试网站127.0.0.1 已拒绝连接,如何解决?(标签-ubuntu)