note 90664 modified in function.system by danbrown

From: Date: Mon, 04 May 2009 12:54:27 +0000
Subject: note 90664 modified in function.system by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154179@lists.php.net to get a copy of this message
This is a work-around that makes the program run in it's own directory instead of the script's. example usage: <?php runAsynchronously("c:\games\jazz2\jazz2.exe","-connect 1.2.3.4"); ?> <?php function runAsynchronously($path,$arguments) { $WshShell = new COM("WScript.Shell"); $oShellLink = $WshShell->CreateShortcut("temp.lnk"); $oShellLink->TargetPath = $path; $oShellLink->Arguments = $arguments; $oShellLink->WorkingDirectory = dirname($path); $oShellLink->WindowStyle = 1; $oShellLink->Save(); $oExec = $WshShell->Run("temp.lnk", 7, false); unset($WshShell,$oShellLink,$oExec); unlink("temp.lnk"); } ?> --was-- This is a work-around that makes the program run in it's own directory instead of the script's. example usage: runAsynchronously("c:\games\jazz2\jazz2.exe","-connect 1.2.3.4"); function runAsynchronously($path,$arguments) { $WshShell = new COM("WScript.Shell"); $oShellLink = $WshShell->CreateShortcut("temp.lnk"); $oShellLink->TargetPath = $path; $oShellLink->Arguments = $arguments; $oShellLink->WorkingDirectory = dirname($path); $oShellLink->WindowStyle = 1; $oShellLink->Save(); $oExec = $WshShell->Run("temp.lnk", 7, false); unset($WshShell,$oShellLink,$oExec); unlink("temp.lnk"); } http://php.net/manual/en/function.system.php

« previous php.notes (#154179) next »