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 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划