123 $rebuildResult = array();
126 if ( !empty( $row ) ) {
127 $rebuildResult[] = preg_replace(
'/[\x00-\x1F\x80-\xFF]/',
'', $row );
132 $this->latestError = implode(
' ; ',
$result );
150 usleep( self::SLEEP_TIME );
155 while ( $this->latestStatus == self::STATUS_NA || $this->
isPending( $this->latestStatus ) ) {
156 $exec = $this->
exec(
'status ' . $this->
getName() );
157 if ( $exec !==
false ) {
158 if ( count( $exec ) > 1 ) {
162 $this->latestStatus = $exec[0];
165 if ( $timeout && $maxtime < time() ) {
170 if ( $this->latestStatus == self::STATUS_NOT_EXIST ) {
171 $this->latestError =
'Error 3: The specified service does not exist as an installed service.';
185 $this->
writeLog(
'Create service' );
198 if ( $exec ===
false ) {
203 $exec = $this->
exec(
'set ' . $this->
getName() .
' AppParameters "' . $this->
getParams() .
'"' );
204 if ( $exec ===
false ) {
210 if ( $exec ===
false ) {
216 if ( $exec ===
false ) {
221 $exec = $this->
exec(
'set ' . $this->
getName() .
' AppNoConsole "1"' );
222 if ( $exec ===
false ) {
228 if ( $exec ===
false ) {
234 if ( $exec ===
false ) {
240 if ( $exec ===
false ) {
246 if ( $exec ===
false ) {
251 $this->latestError =
null;
264 public function delete()
269 $exec = $this->
exec(
'remove ' . $this->
getName() .
' confirm' );
270 if ( $exec ===
false ) {
275 $this->latestError =
null;
292 $exec = $this->
exec(
'start ' . $this->
getName() );
293 if ( $exec ===
false ) {
298 $this->latestError =
null;
316 if ( $exec ===
false ) {
321 $this->latestError =
null;
336 if ( $this->
stop() ) {
337 return $this->
start();
350 global $bearsamppRegistry;
353 if ( $infos ===
false ) {
357 $infosNssm = array();
359 self::INFO_APPLICATION,
360 self::INFO_APP_PARAMETERS,
363 foreach ( $infosKeys as $infoKey ) {
365 $exists = $bearsamppRegistry->exists(
367 'SYSTEM\CurrentControlSet\Services\\' . $this->
getName() .
'\Parameters',
371 $value = $bearsamppRegistry->getValue(
373 'SYSTEM\CurrentControlSet\Services\\' . $this->
getName() .
'\Parameters',
377 $infosNssm[$infoKey] = $value;
380 if ( !isset( $infosNssm[self::INFO_APPLICATION] ) ) {
396 $status = $this->
status();
397 $this->
writeLog(
'isInstalled ' . $this->
getName() .
': ' . ($status != self::STATUS_NA ?
'YES' :
'NO') .
' (status: ' . $status .
')' );
409 $status = $this->
status();
410 $this->
writeLog(
'isRunning ' . $this->
getName() .
': ' . ($status == self::STATUS_RUNNING ?
'YES' :
'NO') .
' (status: ' . $status .
')' );
422 $status = $this->
status();
423 $this->
writeLog(
'isStopped ' . $this->
getName() .
': ' . ($status == self::STATUS_STOPPED ?
'YES' :
'NO') .
' (status: ' . $status .
')' );
435 $status = $this->
status();
436 $this->
writeLog(
'isPaused ' . $this->
getName() .
': ' . ($status == self::STATUS_PAUSED ?
'YES' :
'NO') .
' (status: ' . $status .
')' );
450 return $status == self::STATUS_START_PENDING || $status == self::STATUS_STOP_PENDING
465 return 'The service continue is pending.';
468 return 'The service pause is pending.';
471 return 'The service is paused.';
474 return 'The service is running.';
477 return 'The service is starting.';
480 return 'The service is stopping.';
483 return 'The service is not running.';
486 return 'Cannot retrieve service status.';
682 if ( !empty( $this->latestError ) ) {
685 elseif ( $this->latestStatus != self::STATUS_NA ) {
686 return $bearsamppLang->getValue(
Lang::STATUS ) .
' ' . $this->latestStatus .
' : ' . $this->getWin32ServiceStatusDesc( $this->latestStatus );
static exec($basename, $content, $timeout=true, $catchOutput=true, $standalone=false, $silent=true, $rebuild=true)
getServiceStatusDesc($status)
const SERVICE_DELAYED_START
setEnvironmentExtra($environmentExtra)
setDisplayName($displayName)
const STATUS_START_PENDING
const STATUS_CONTINUE_PENDING
const SERVICE_DEMAND_START
const INFO_APP_ENVIRONMENT_EXTRA
const STATUS_PAUSE_PENDING
const SERVICE_INTERACTIVE_PROCESS
const STATUS_STOP_PENDING
const SERVICE_WIN32_OWN_PROCESS
const INFO_APP_PARAMETERS
static logError($data, $file=null)
static logDebug($data, $file=null)
static logInitClass($classInstance)
static logInfo($data, $file=null)
static formatWindowsPath($path)
static getServiceInfos($serviceName)