Question

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=============\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);
        }
    }

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.

Was it helpful?

Solution 2

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

OTHER TIPS

Try this (copied from forum on another site)

Copy the following files in System32 directory 1. libmysql.dll 2. msql.dll

Copy the following files in php\ext directory 1. msql.dll . This file should be copied when you extract the PHP 5 zip file, but obviously its not

Restart webserver

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top