我有一個實現Quartz.NET調度的Windows服務,它從XML文件讀取預定作業信息,解析它以便運行cmd行,並使用解析的參數創建預定作業。Quartz.NET:在PHP_mssql.dll上運行PHP cmd行導致ACCESS DENIED?
我目前正在使用PHP命令行腳本來測試調度程序的命令行執行情況,它似乎開始工作就好,他們甚至成功完成,顯示腳本輸出在eventLog中...
的問題是在每次運行時,彈出式警告顯示出現錯誤:
「PHP啓動:無法加載動態庫‘C:\ PHP5 \ php_mssql.dll’ - 訪問被拒絕」
如果我對此警告做出響應,腳本看起來運行良好,但如果它仍保留在屏幕上,則進一步調度PHP腳本s將運行到完成,但輸出是空的(我假設在它之前運行的暫停作業被暫停)。...
如何以編程方式阻止該訪問被拒絕消息?在運行分析CMD線
的Quartz.NET作業執行腳本如下:
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世界,它不與數據庫交互,但我有一種感覺,如果我DID運行一個使用數據庫功能,它會因爲訪問被拒絕消息而失敗...這也是不能接受的,我必須能夠爲這個項目全面使用PHP!
EDIT2:我已經使用Windows LocalService帳戶安裝了該服務。
這需要我修改此Windows服務安裝到的服務器上的文件配置,這可能無法在運行此調度程序服務的生產環境中進行......是否可以將任何路徑添加到進程以允許此操作? – Rimer 2010-12-01 17:41:59