<?php
/* version: 20170415 */
function O__launchProgram($O__appPathStart,$O__appBin,$O__appParameters){
	global $O__DBpath, $O__launchMethod, $O__launchUser, $O__launchPW, $O__launchDisplay;
	
	switch($O__launchMethod){
		case "psexec":
			exec("D:/programs/bins/psexec.exe -d -i -u " . $O__launchUser . " -p " . $O__launchPW . " -w \"" . $O__appPathStart . "\" \"" . $O__appPathStart . $O__appBin . "\" " . $O__appParameters);
		break;
		
		case "cmd":
			exec("C:\WINDOWS\system32\cmd.exe /B /C START " . $O__appPathStart . $O__appBin . " " . $O__appParameters);	
		break;
		
		case "shell":
			$O__shell = "#!/bin/bash\r\n";
			$O__shell .= "#sudo xhost +localhost\r\n";
			$O__shell .= "export DISPLAY=" . $O__launchDisplay . "\r\n";
			$O__shell .= "sudo -u " . $O__launchUser . " " . $O__appPathStart . $O__appBin . " " . $O__appParameters;
			
			$O__shellPath = $O__DBpath . "/temp/" . "O__launchProgram.sh";
			O__dataWrite($O__shellPath,$O__shell);
			
			passthru($O__shellPath . " " . $O__appBin . " " . $O__appParameters . " > /dev/null 2>&1 &");
			unlink($O__shellPath);
	
			//passthru("sudo -u " . $O__launchUser . " " . $O__appPathStart . $O__appBin . " " . $O__appParameters);
			
			//shell_exec("sudo -u " . $O__launchUser . " " . $O__appPathStart . $O__appBin . " " . $O__appParameters . " > /dev/null 2>&1 &");
	
		break;
	}
}
?>
