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 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思