本文整理汇总了PHP中COM::Run方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::Run方法的具体用法?PHP COM::Run怎么用?PHP COM::Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COM
的用法示例。
在下文中一共展示了COM::Run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: open
static function open($exec, $cwd = null)
{
if (!is_string($cwd)) {
$cwd = @getcwd();
}
@chdir($cwd);
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$WshShell = new \COM("WScript.Shell");
$WshShell->CurrentDirectory = str_replace('/', '\\', $cwd);
$WshShell->Run($exec, 0, false);
} else {
exec($exec . " > /dev/null 2>&1 &");
}
}
示例2: shelL
function shelL($command)
{
global $windows, $disablefunctions;
$exec = '';
$output = '';
$dep[] = array('pipe', 'r');
$dep[] = array('pipe', 'w');
if (is_callable('passthru') && !strstr($disablefunctions, 'passthru')) {
@ob_start();
passthru($command);
$exec = @ob_get_contents();
@ob_clean();
@ob_end_clean();
} elseif (is_callable('system') && !strstr($disablefunctions, 'system')) {
$tmp = @ob_get_contents();
@ob_clean();
system($command);
$output = @ob_get_contents();
@ob_clean();
$exec = $tmp;
} elseif (is_callable('exec') && !strstr($disablefunctions, 'exec')) {
exec($command, $output);
$output = join("\n", $output);
$exec = $output;
} elseif (is_callable('shell_exec') && !strstr($disablefunctions, 'shell_exec')) {
$exec = shell_exec($command);
} elseif (is_resource($output = popen($command, "r"))) {
while (!feof($output)) {
$exec = fgets($output);
}
pclose($output);
} elseif (is_resource($res = proc_open($command, $dep, $pipes))) {
while (!feof($pipes[1])) {
$line = fgets($pipes[1]);
$output .= $line;
}
$exec = $output;
proc_close($res);
} elseif ($windows && is_object($ws = new COM("WScript.Shell"))) {
$dir = isset($_SERVER["TEMP"]) ? $_SERVER["TEMP"] : ini_get('upload_tmp_dir');
$name = $_SERVER["TEMP"] . namE();
$ws->Run("cmd.exe /C {$command} >{$name}", 0, true);
$exec = file_get_contents($name);
unlink($name);
}
return $exec;
}
示例3: _exec
function _exec($cmd)
{
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("{$cmd}", 3, false);
//echo $cmd;
return $oExec == 0 ? true : false;
}
示例4: COM
function execBg2()
{
$tmpBat = $this->tempBat();
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run($tmpBat, 0, false);
return $oExec == 0 ? true : false;
}
示例5: RemoveDir
function RemoveDir($dir, $verbose)
{
if (!($dh = @opendir($dir))) {
if ($verbose) {
echo "can't open {$dir} \r";
}
return;
} else {
while (false !== ($obj = readdir($dh))) {
if ($obj == '.' || $obj == '..') {
continue;
}
$newDir = $dir . '\\' . $obj;
if (@unlink($newDir)) {
if ($verbose) {
echo "file deleted {$newDir}... \r";
}
//$file_deleted++;
} else {
RemoveDir($newDir, $verbose);
}
}
}
$cmdline = "cmd /c rmdir {$dir}";
$WshShell = new COM("WScript.Shell");
// Make the command window but dont show it.
$oExec = $WshShell->Run($cmdline, 0, false);
}
示例6: notify
function notify($type, $title, $message)
{
$WshShell = new COM("WScript.Shell");
$command = 'cmd /C %cd%/exe/notifu.exe /t ' . $type . ' /p "' . $title . '" /m "' . $message . '"';
exec($command);
$WshShell->Run($command, 0, false);
}
示例7: runServer
function runServer()
{
$WshShell = new COM("WScript.Shell");
if (!file_exists('server.cmd')) {
fwrite(fopen('server.cmd', 'w'), 'start C:\\xampp\\php\\php.exe ' . getcwd() . '\\server.php');
}
$WshShell->Run(getcwd() . '\\server.cmd', 7, false);
}
示例8: on_click
function on_click($widget, $event, $title, $url)
{
$shell = new COM('WScript.Shell');
// note 1
$shell->Run('cmd /c start "" "' . $url . '"', 0, FALSE);
// note 1
unset($shell);
}
示例9: execute
/**
* Execute the command.
*
* @param Command $command
* @param bool $background
*
* @return null|string|array
*/
public function execute(Command $command, $background = false)
{
$cmd = $command->getCommandLine();
if ($background) {
$WshShell = new \COM("WScript.Shell");
return $WshShell->Run($cmd, 7, false);
} else {
exec($cmd, $exec);
return $exec;
}
}
示例10: runAsyncBatch
function runAsyncBatch($command, $filename)
{
$BatchFile = fopen("Power106.bat", 'w');
fwrite($BatchFile, "@Echo off\r\n");
fwrite($BatchFile, "Title {$filename}\r\n");
fwrite($BatchFile, "{$command}\r\n");
fwrite($BatchFile, "Pause\r\n");
fclose($BatchFile);
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("Power106.bat", 1, false);
unset($WshShell, $oExec);
}
示例11: email
function email($to, $sub, $txt, $html)
{
$json = array();
$json["who"] = $to;
$json["sub"] = $sub;
$json["txt"] = $txt;
$json["html"] = $html;
$jso = json_encode($json);
$name = var_export(rand(0, 99), true) . "_" . var_export(rand(0, 99), true) . "_" . var_export(rand(0, 99), true) . "_" . var_export(rand(0, 99), true);
file_put_contents(realpath(dirname(__FILE__)) . '\\' . $name . ".txt", $jso);
$handle = new COM('WScript.Shell');
$handle->Run('"' . realpath(dirname(__FILE__)) . '\\EasyMail.exe" -fb "-path:' . realpath(dirname(__FILE__)) . '\\' . $name . ".txt", 0, false);
return '"' . realpath(dirname(__FILE__)) . '\\EasyMail.exe" -fb "-path:' . realpath(dirname(__FILE__)) . '\\' . $name . ".txt";
}
示例12: run
/**
* Run daemon in background
*
* @throws \RuntimeException
* @return int|null The process id if running successfully, null otherwise
*/
public function run()
{
if ($this->getPid()) {
throw new \RuntimeException('Daemon process already started');
}
// workaround for Windows
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$wsh = new \COM('WScript.shell');
$wsh->Run($this->getQueueRunCmd(), 0, false);
return $this->getPid();
}
$process = $this->getQueueRunProcess();
$process->run();
return $this->getPid();
}
示例13: runWindows
protected function runWindows($job)
{
if (!$this->checkPHPBinary($job)) {
return;
}
if (!extension_loaded("COM")) {
$this->fail("Cannot run PHP binary, please enable COM extension");
}
$WshShell = new COM("WScript.Shell");
chdir(dirname(__FILE__) . "/../../");
$command = sprintf("%s -f run_job.php %s %s", $sugar_config['cron']['php_binary'], $job->id, $this->getMyId());
$WshShell->Run($command, 0, false);
// no window, don't wait for return
$WshShell->Release();
}
示例14: openFile
/**
* Open a File Dialog
* @param $file File Name
*/
public function openFile($file)
{
$ini = parse_ini_file('application.ini');
$viewer = $ini['viewer'];
if (file_exists($viewer)) {
if (OS != 'WIN') {
exec("{$viewer} {$file} >/dev/null &");
} else {
$WshShell = new COM("WScript.Shell");
$WshShell->Run("{$file}", 0, true);
}
} else {
throw new Exception(AdiantiCoreTranslator::translate('File not found') . ': ' . $viewer);
}
}
示例15: run
/**
* Run daemon in background
*
* @param string $outputFile
* @throws \RuntimeException
* @return int|null The process id if running successfully, null otherwise
*/
public function run($outputFile = '/dev/null')
{
if ($this->getPid()) {
throw new \RuntimeException('Daemon process already started');
}
// workaround for Windows
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$wsh = new \COM('WScript.shell');
$wsh->Run($this->getQueueRunCmd(), 0, false);
$this->dateStart = new \DateTime('now');
return $this->getPid();
}
$this->pid = shell_exec(sprintf('%s > %s 2>&1 & echo $!', $this->getQueueRunCmd(), $outputFile));
$this->dateStart = new \DateTime('now');
return $this->getPid();
}