Bearsampp 2026.3.26
API documentation
Loading...
Searching...
No Matches
class.vbs.php
Go to the documentation of this file.
1<?php
2/*
3 *
4 * * Copyright (c) 2022-2025 Bearsampp
5 * * License: GNU General Public License version 3 or later; see LICENSE.txt
6 * * Website: https://bearsampp.com
7 * * Github: https://github.com/Bearsampp
8 *
9 */
10
18class Vbs
19{
20 const END_PROCESS_STR = 'FINISHED!';
21 const STR_SEPARATOR = ' || ';
22
23 const DESKTOP_PATH = 'objShell.SpecialFolders("Desktop")';
24 const ALL_DESKTOP_PATH = 'objShell.SpecialFolders("AllUsersDesktop")';
25 const STARTUP_PATH = 'objShell.SpecialFolders("Startup")';
26 const ALL_STARTUP_PATH = 'objShell.SpecialFolders("AllUsersStartup")';
27
28 public function __construct()
29 {
30 }
31
37 private static function writeLog($log)
38 {
39 global $bearsamppRoot;
40 Util::logDebug( $log, $bearsamppRoot->getVbsLogFilePath() );
41 }
42
50 public static function countFilesFolders($path)
51 {
52 $basename = 'countFilesFolders';
53 $resultFile = self::getResultFile( $basename );
54
55 $content = 'Dim objFso, objResultFile, objCheckFile' . PHP_EOL . PHP_EOL;
56 $content .= 'Set objFso = CreateObject("scripting.filesystemobject")' . PHP_EOL;
57 $content .= 'Set objResultFile = objFso.CreateTextFile("' . $resultFile . '", True)' . PHP_EOL;
58 $content .= 'count = 0' . PHP_EOL;
59 $content .= 'CountFiles("' . $path . '")' . PHP_EOL . PHP_EOL;
60 $content .= 'Function CountFiles(ByVal path)' . PHP_EOL;
61 $content .= ' Dim parentFld, subFld' . PHP_EOL;
62 $content .= ' Set parentFld = objFso.GetFolder(path)' . PHP_EOL . PHP_EOL;
63 $content .= ' count = count + parentFld.Files.Count + parentFld.SubFolders.Count' . PHP_EOL;
64 $content .= ' For Each subFld In parentFld.SubFolders' . PHP_EOL;
65 $content .= ' count = count + CountFiles(subFld.Path)' . PHP_EOL;
66 $content .= ' Next' . PHP_EOL . PHP_EOL;
67 $content .= 'End Function' . PHP_EOL . PHP_EOL;
68 $content .= 'objResultFile.Write count' . PHP_EOL;
69 $content .= 'objResultFile.Close' . PHP_EOL;
70
71 $result = self::exec( $basename, $resultFile, $content );
72
73 return isset( $result[0] ) && is_numeric( $result[0] ) ? intval( $result[0] ) : false;
74 }
75
81 public static function getDefaultBrowser()
82 {
83 $basename = 'getDefaultBrowser';
84 $resultFile = self::getResultFile( $basename );
85
86 $content = 'On Error Resume Next' . PHP_EOL;
87 $content .= 'Err.Clear' . PHP_EOL . PHP_EOL;
88 $content .= 'Dim objShell, objFso, objFile' . PHP_EOL . PHP_EOL;
89 $content .= 'Set objShell = WScript.CreateObject("WScript.Shell")' . PHP_EOL;
90 $content .= 'Set objFso = CreateObject("scripting.filesystemobject")' . PHP_EOL;
91 $content .= 'Set objFile = objFso.CreateTextFile("' . $resultFile . '", True)' . PHP_EOL . PHP_EOL;
92 $content .= 'objFile.Write objShell.RegRead("HKLM\SOFTWARE\Classes\http\shell\open\command\")' . PHP_EOL;
93 $content .= 'objFile.Close' . PHP_EOL;
94
95 $result = self::exec( $basename, $resultFile, $content );
96 if ( $result !== false && !empty( $result ) ) {
97 if ( preg_match( '/"([^"]+)"/', $result[0], $matches ) ) {
98 return $matches[1];
99 }
100 else {
101 return str_replace( '"', '', $result[0] );
102 }
103 }
104 else {
105 return false;
106 }
107 }
108
114 public static function getInstalledBrowsers()
115 {
116 $basename = 'getInstalledBrowsers';
117 $resultFile = self::getResultFile( $basename );
118
119 $content = 'On Error Resume Next' . PHP_EOL;
120 $content .= 'Err.Clear' . PHP_EOL . PHP_EOL;
121 $content .= 'Dim objShell, objRegistry, objFso, objFile, browserPath' . PHP_EOL . PHP_EOL;
122 $content .= 'Set objShell = WScript.CreateObject("WScript.Shell")' . PHP_EOL;
123 $content .= 'Set objRegistry = GetObject("winmgmts://./root/default:StdRegProv")' . PHP_EOL;
124 $content .= 'Set objFso = CreateObject("scripting.filesystemobject")' . PHP_EOL;
125 $content .= 'Set objFile = objFso.CreateTextFile("' . $resultFile . '", True)' . PHP_EOL . PHP_EOL;
126
127 // Check HKLM (system-wide browsers)
128 $content .= 'mainKey = "SOFTWARE\WOW6432Node\Clients\StartMenuInternet"' . PHP_EOL;
129 $content .= 'checkKey = objShell.RegRead("HKLM\" & mainKey & "\")' . PHP_EOL;
130 $content .= 'If Err.Number <> 0 Then' . PHP_EOL;
131 $content .= ' Err.Clear' . PHP_EOL;
132 $content .= ' mainKey = "SOFTWARE\Clients\StartMenuInternet"' . PHP_EOL;
133 $content .= ' checkKey = objShell.RegRead("HKLM\" & mainKey & "\")' . PHP_EOL;
134 $content .= ' If Err.Number <> 0 Then' . PHP_EOL;
135 $content .= ' mainKey = ""' . PHP_EOL;
136 $content .= ' End If' . PHP_EOL;
137 $content .= 'End If' . PHP_EOL . PHP_EOL;
138 $content .= 'Err.Clear' . PHP_EOL;
139 $content .= 'If mainKey <> "" Then' . PHP_EOL;
140 $content .= ' objRegistry.EnumKey &H80000002, mainKey, arrSubKeys' . PHP_EOL;
141 $content .= ' For Each subKey In arrSubKeys' . PHP_EOL;
142 $content .= ' Err.Clear' . PHP_EOL;
143 $content .= ' browserPath = objShell.RegRead("HKLM\" & mainKey & "\" & subKey & "\shell\open\command\")' . PHP_EOL;
144 $content .= ' If Err.Number = 0 And browserPath <> "" Then' . PHP_EOL;
145 $content .= ' objFile.Write browserPath & vbCrLf' . PHP_EOL;
146 $content .= ' End If' . PHP_EOL;
147 $content .= ' Err.Clear' . PHP_EOL;
148 $content .= ' Next' . PHP_EOL;
149 $content .= 'End If' . PHP_EOL . PHP_EOL;
150
151 // Check HKCU (user-installed browsers like Brave)
152 $content .= 'Err.Clear' . PHP_EOL;
153 $content .= 'userKey = "SOFTWARE\Clients\StartMenuInternet"' . PHP_EOL;
154 $content .= 'checkKey = objShell.RegRead("HKCU\" & userKey & "\")' . PHP_EOL;
155 $content .= 'If Err.Number = 0 Then' . PHP_EOL;
156 $content .= ' Err.Clear' . PHP_EOL;
157 $content .= ' objRegistry.EnumKey &H80000001, userKey, arrUserSubKeys' . PHP_EOL;
158 $content .= ' If Not IsEmpty(arrUserSubKeys) Then' . PHP_EOL;
159 $content .= ' For Each subKey In arrUserSubKeys' . PHP_EOL;
160 $content .= ' Err.Clear' . PHP_EOL;
161 $content .= ' browserPath = objShell.RegRead("HKCU\" & userKey & "\" & subKey & "\shell\open\command\")' . PHP_EOL;
162 $content .= ' If Err.Number = 0 And browserPath <> "" Then' . PHP_EOL;
163 $content .= ' objFile.Write browserPath & vbCrLf' . PHP_EOL;
164 $content .= ' End If' . PHP_EOL;
165 $content .= ' Err.Clear' . PHP_EOL;
166 $content .= ' Next' . PHP_EOL;
167 $content .= ' End If' . PHP_EOL;
168 $content .= 'End If' . PHP_EOL . PHP_EOL;
169
170 $content .= 'objFile.Close' . PHP_EOL;
171
172 $result = self::exec( $basename, $resultFile, $content );
173 if ( $result !== false && !empty( $result ) ) {
174 $rebuildResult = array();
175 foreach ( $result as $browser ) {
176 $rebuildResult[] = str_replace( '"', '', $browser );
177 }
178 $result = $rebuildResult;
179 }
180
181 return $result;
182 }
183
191 public static function getListProcs($vbsKeys)
192 {
193 $basename = 'getListProcs';
194 $resultFile = self::getResultFile( $basename );
195 $sep = ' & "' . self::STR_SEPARATOR . '" & _';
196
197 $content = 'Dim objFso, objResultFile, objWMIService' . PHP_EOL . PHP_EOL;
198 $content .= 'Set objFso = CreateObject("scripting.filesystemobject")' . PHP_EOL;
199 $content .= 'Set objResultFile = objFso.CreateTextFile("' . $resultFile . '", True)' . PHP_EOL;
200 $content .= 'strComputer = "."' . PHP_EOL;
201 $content .= 'Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\\\" & strComputer & "\root\cimv2")' . PHP_EOL;
202 $content .= 'Set listProcess = objWMIService.ExecQuery ("SELECT * FROM Win32_Process")' . PHP_EOL;
203 $content .= 'For Each process in listProcess' . PHP_EOL;
204
205 $content .= ' objResultFile.WriteLine(_' . PHP_EOL;
206 foreach ( $vbsKeys as $vbsKey ) {
207 $content .= ' process.' . $vbsKey . $sep . PHP_EOL;
208 }
209 $content = substr( $content, 0, strlen( $content ) - strlen( $sep ) - 1 ) . ')' . PHP_EOL;
210
211 $content .= 'Next' . PHP_EOL;
212 $content .= 'objResultFile.WriteLine("' . self::END_PROCESS_STR . '")' . PHP_EOL;
213 $content .= 'objResultFile.Close' . PHP_EOL;
214 $content .= 'Err.Clear' . PHP_EOL;
215
216 $result = self::exec( $basename, $resultFile, $content );
217 if ( empty( $result ) ) {
218 return false;
219 }
220
221 unset( $result[array_search( self::END_PROCESS_STR, $result )] );
222 if ( is_array( $result ) && count( $result ) > 0 ) {
223 $rebuildResult = array();
224 foreach ( $result as $row ) {
225 $row = explode( trim( self::STR_SEPARATOR ), $row );
226 if ( count( $row ) != count( $vbsKeys ) ) {
227 continue;
228 }
229 $processInfo = array();
230 foreach ( $vbsKeys as $key => $vbsKey ) {
231 $processInfo[$vbsKey] = trim( $row[$key] );
232 }
233 if ( !empty( $processInfo[Win32Ps::EXECUTABLE_PATH] ) ) {
234 $rebuildResult[] = $processInfo;
235 }
236 }
237
238 return $rebuildResult;
239 }
240
241 return false;
242 }
243
251 public static function killProc($pid)
252 {
253 $basename = 'killProc';
254 $resultFile = self::getResultFile( $basename );
255
256 $content = 'Dim objFso, objResultFile, objWMIService, processFound' . PHP_EOL . PHP_EOL;
257 $content .= 'Set objFso = CreateObject("scripting.filesystemobject")' . PHP_EOL;
258 $content .= 'Set objResultFile = objFso.CreateTextFile("' . $resultFile . '", True)' . PHP_EOL;
259 $content .= 'strComputer = "."' . PHP_EOL;
260 $content .= 'strProcessKill = "' . $pid . '"' . PHP_EOL;
261 $content .= 'processFound = False' . PHP_EOL;
262 $content .= 'Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\\\" & strComputer & "\root\cimv2")' . PHP_EOL;
263 $content .= 'Set listProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where ProcessID = " & strProcessKill)' . PHP_EOL;
264 $content .= 'For Each objProcess in listProcess' . PHP_EOL;
265 $content .= ' processFound = True' . PHP_EOL;
266 $content .= ' objResultFile.WriteLine(objProcess.Name & "' . self::STR_SEPARATOR . '" & objProcess.ProcessID & "' . self::STR_SEPARATOR . '" & objProcess.ExecutablePath)' . PHP_EOL;
267 $content .= ' objProcess.Terminate()' . PHP_EOL;
268 $content .= 'Next' . PHP_EOL;
269 $content .= 'If Not processFound Then' . PHP_EOL;
270 $content .= ' objResultFile.WriteLine("PROCESS_NOT_FOUND' . self::STR_SEPARATOR . '" & strProcessKill & "' . self::STR_SEPARATOR . '")' . PHP_EOL;
271 $content .= 'End If' . PHP_EOL;
272 $content .= 'objResultFile.Close' . PHP_EOL;
273
274 $result = self::exec( $basename, $resultFile, $content );
275 if ( empty( $result ) ) {
276 return true;
277 }
278
279 if ( is_array( $result ) && count( $result ) > 0 ) {
280 foreach ( $result as $row ) {
281 $row = explode( self::STR_SEPARATOR, $row );
282 if ( count( $row ) == 3 ) {
283 if ( $row[0] === 'PROCESS_NOT_FOUND' ) {
284 Util::logDebug( 'Process with PID ' . $row[1] . ' not found' );
285 } elseif ( !empty( $row[2] ) ) {
286 Util::logDebug( 'Kill process ' . $row[2] . ' (PID ' . $row[1] . ')' );
287 }
288 }
289 }
290 }
291
292 return true;
293 }
294
302 private static function getSpecialPath($path)
303 {
304 $basename = 'getSpecialPath';
305 $resultFile = self::getResultFile( $basename );
306
307 $content = 'Dim objShell, objFso, objResultFile' . PHP_EOL . PHP_EOL;
308 $content .= 'Set objShell = Wscript.CreateObject("Wscript.Shell")' . PHP_EOL;
309 $content .= 'Set objFso = CreateObject("scripting.filesystemobject")' . PHP_EOL;
310 $content .= 'Set objResultFile = objFso.CreateTextFile("' . $resultFile . '", True)' . PHP_EOL . PHP_EOL;
311 $content .= 'objResultFile.WriteLine(' . $path . ')' . PHP_EOL;
312 $content .= 'objResultFile.Close' . PHP_EOL;
313
314 $result = self::exec( $basename, $resultFile, $content );
315 if ( !empty( $result ) && is_array( $result ) && count( $result ) == 1 ) {
316 return Util::formatUnixPath( $result[0] );
317 }
318
319 return null;
320 }
321
329 public static function getStartupPath($file = null)
330 {
331 return self::getSpecialPath( self::STARTUP_PATH ) . ($file != null ? '/' . $file : '');
332 }
333
341 public static function createShortcut($savePath)
342 {
344 $basename = 'createShortcut';
345 $resultFile = self::getResultFile( $basename );
346
347 $content = 'Dim objShell, objFso, objResultFile' . PHP_EOL . PHP_EOL;
348 $content .= 'Set objShell = Wscript.CreateObject("Wscript.Shell")' . PHP_EOL;
349 $content .= 'Set objFso = CreateObject("scripting.filesystemobject")' . PHP_EOL;
350 $content .= 'Set objResultFile = objFso.CreateTextFile("' . $resultFile . '", True)' . PHP_EOL . PHP_EOL;
351 $content .= 'Set objShortcut = objShell.CreateShortcut("' . $savePath . '")' . PHP_EOL;
352 $content .= 'objShortCut.TargetPath = "' . $bearsamppRoot->getExeFilePath() . '"' . PHP_EOL;
353 $content .= 'objShortCut.WorkingDirectory = "' . $bearsamppRoot->getRootPath() . '"' . PHP_EOL;
354 $content .= 'objShortCut.Description = "' . APP_TITLE . ' ' . $bearsamppCore->getAppVersion() . '"' . PHP_EOL;
355 $content .= 'objShortCut.IconLocation = "' . $bearsamppCore->getIconsPath() . '/app.ico' . '"' . PHP_EOL;
356 $content .= 'objShortCut.Save' . PHP_EOL;
357 $content .= 'If Err.Number <> 0 Then' . PHP_EOL;
358 $content .= ' objResultFile.Write Err.Number & ": " & Err.Description' . PHP_EOL;
359 $content .= 'End If' . PHP_EOL;
360 $content .= 'objResultFile.Close' . PHP_EOL;
361
362 $result = self::exec( $basename, $resultFile, $content );
363 if ( empty( $result ) ) {
364 return true;
365 }
366 elseif ( isset( $result[0] ) ) {
367 Util::logError( 'createShortcut: ' . $result[0] );
368
369 return false;
370 }
371
372 return false;
373 }
374
382 public static function getServiceInfos($serviceName)
383 {
384 $basename = 'getServiceInfos';
385 $resultFile = self::getResultFile( $basename );
386 $sep = ' & "' . self::STR_SEPARATOR . '" & _';
387 $vbsKeys = Win32Service::getVbsKeys();
388
389 $content = 'Dim objFso, objResultFile, objWMIService' . PHP_EOL . PHP_EOL;
390 $content .= 'Set objFso = CreateObject("scripting.filesystemobject")' . PHP_EOL;
391 $content .= 'Set objResultFile = objFso.CreateTextFile("' . $resultFile . '", True)' . PHP_EOL;
392 $content .= 'strComputer = "."' . PHP_EOL;
393 $content .= 'Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\\\" & strComputer & "\root\cimv2")' . PHP_EOL;
394 $content .= 'Set listServices = objWMIService.ExecQuery ("SELECT * FROM Win32_Service WHERE Name=\'' . $serviceName . '\'")' . PHP_EOL;
395 $content .= 'For Each service in listServices' . PHP_EOL;
396
397 $content .= ' objResultFile.WriteLine(_' . PHP_EOL;
398 foreach ( $vbsKeys as $vbsKey ) {
399 $content .= ' service.' . $vbsKey . $sep . PHP_EOL;
400 }
401 $content = substr( $content, 0, strlen( $content ) - strlen( $sep ) - 1 ) . ')' . PHP_EOL;
402
403 $content .= 'Next' . PHP_EOL;
404 $content .= 'objResultFile.WriteLine("' . self::END_PROCESS_STR . '")' . PHP_EOL;
405 $content .= 'objResultFile.Close' . PHP_EOL;
406
407 $result = self::exec( $basename, $resultFile, $content );
408 if ( empty( $result ) ) {
409 return false;
410 }
411
412 unset( $result[array_search( self::END_PROCESS_STR, $result )] );
413 if ( is_array( $result ) && count( $result ) == 1 ) {
414 $rebuildResult = array();
415 $row = explode( trim( self::STR_SEPARATOR ), $result[0] );
416 if ( count( $row ) != count( $vbsKeys ) ) {
417 return false;
418 }
419 foreach ( $vbsKeys as $key => $vbsKey ) {
420 $rebuildResult[$vbsKey] = trim( $row[$key] );
421 }
422
423 return $rebuildResult;
424 }
425
426 return false;
427 }
428
437 public static function getTmpFile($ext, $customName = null)
438 {
439 global $bearsamppCore;
440
441 return Util::formatWindowsPath( $bearsamppCore->getTmpPath() . '/' . (!empty( $customName ) ? $customName . '-' : '') . Util::random() . $ext );
442 }
443
451 public static function getResultFile($basename)
452 {
453 return self::getTmpFile( '.vbs', $basename );
454 }
455
466 public static function exec($basename, $resultFile, $content, $timeout = true)
467 {
468 global $bearsamppConfig, $bearsamppWinbinder;
469 $result = false;
470
471 $scriptPath = self::getTmpFile( '.vbs', $basename );
472 $checkFile = self::getTmpFile( '.tmp', $basename );
473 $errFile = self::getTmpFile( '.tmp', $basename );
474 $randomVarName = Util::random( 15, false );
475 $randomObjErrFile = Util::random( 15, false );
476 $randomObjFile = Util::random( 15, false );
477 $randomObjFso = Util::random( 15, false );
478
479 // Add a timeout to the VBScript itself
480 $timeoutSeconds = 10; // 10 seconds timeout for the VBScript
481
482 // Header with timeout
483 $header = 'On Error Resume Next' . PHP_EOL .
484 'Dim ' . $randomVarName . ', ' . $randomObjFso . ', ' . $randomObjErrFile . ', ' . $randomObjFile . PHP_EOL .
485 'Set ' . $randomObjFso . ' = CreateObject("scripting.filesystemobject")' . PHP_EOL .
486 'Set ' . $randomObjErrFile . ' = ' . $randomObjFso . '.CreateTextFile("' . $errFile . '", True)' . PHP_EOL .
487 'Set ' . $randomObjFile . ' = ' . $randomObjFso . '.CreateTextFile("' . $checkFile . '", True)' . PHP_EOL .
488 // Add timeout mechanism to VBScript
489 'startTime = Timer' . PHP_EOL .
490 'timeoutSeconds = ' . $timeoutSeconds . PHP_EOL . PHP_EOL;
491
492 // Footer with timeout check
493 $footer = PHP_EOL . PHP_EOL .
494 // Add timeout check before ending
495 'If Timer - startTime > timeoutSeconds Then' . PHP_EOL .
496 $randomObjErrFile . '.Write "VBScript execution timed out after " & timeoutSeconds & " seconds"' . PHP_EOL .
497 'End If' . PHP_EOL .
498 'If Err.Number <> 0 Then' . PHP_EOL .
499 $randomObjErrFile . '.Write Err.Description' . PHP_EOL .
500 'End If' . PHP_EOL .
501 $randomObjFile . '.Write "' . self::END_PROCESS_STR . '"' . PHP_EOL .
502 $randomObjFile . '.Close' . PHP_EOL .
503 $randomObjErrFile . '.Close' . PHP_EOL;
504
505 // Process
506 file_put_contents( $scriptPath, $header . $content . $footer );
507
508 // Use set_time_limit to prevent PHP script timeout
509 $originalTimeout = ini_get('max_execution_time');
510 set_time_limit(30); // 30 seconds timeout for PHP
511
512 Util::logTrace("Starting VBS execution for: " . $basename);
513 $startTime = microtime(true);
514
515 try {
516 $bearsamppWinbinder->exec( 'wscript.exe', '"' . $scriptPath . '"' );
517
518 $timeout = is_numeric( $timeout ) ? $timeout : ($timeout === true ? $bearsamppConfig->getScriptsTimeout() : false);
519 // Use a shorter timeout for VBS execution
520 $timeout = min($timeout, 15); // Maximum 15 seconds
521 $maxtime = time() + $timeout;
522 $noTimeout = $timeout === false;
523
524 // Add a microtime-based timeout as well
525 $microTimeStart = microtime(true);
526 $microTimeMax = 15; // 15 seconds maximum
527
528 $loopCount = 0;
529 $maxLoops = 30; // Maximum number of attempts
530
531 while ( ($result === false || empty( $result )) && $loopCount < $maxLoops ) {
532 $loopCount++;
533
534 if ( file_exists( $checkFile ) ) {
535 $check = file( $checkFile );
536 if ( !empty( $check ) && trim( $check[0] ) == self::END_PROCESS_STR ) {
537 $result = file( $resultFile );
538 Util::logTrace("VBS execution completed successfully after " . $loopCount . " attempts");
539 break;
540 }
541 }
542
543 // Check both timeouts
544 if (($maxtime < time() && !$noTimeout) || (microtime(true) - $microTimeStart > $microTimeMax)) {
545 Util::logTrace("VBS execution timed out after " . round(microtime(true) - $startTime, 2) . " seconds");
546 break;
547 }
548
549 // Sleep a short time to prevent CPU hogging
550 usleep(100000); // 100ms
551 }
552
553 if ($loopCount >= $maxLoops) {
554 Util::logTrace("VBS execution reached maximum loop count (" . $maxLoops . ")");
555 }
556 } catch (\Exception $e) {
557 Util::logTrace("Exception during VBS execution: " . $e->getMessage());
558 } catch (\Throwable $e) {
559 Util::logTrace("Throwable during VBS execution: " . $e->getMessage());
560 } finally {
561 // Reset the timeout
562 set_time_limit($originalTimeout);
563 }
564
565 $executionTime = round(microtime(true) - $startTime, 2);
566 Util::logTrace("VBS execution for " . $basename . " took " . $executionTime . " seconds");
567
568 $err = file_get_contents( $errFile );
569 if ( !empty( $err ) ) {
570 Util::logError( 'VBS error on ' . $basename . ': ' . $err );
571 }
572
573 self::writeLog( 'Exec ' . $basename . ':' );
574 self::writeLog( '-> content: ' . str_replace( PHP_EOL, ' \\\\ ', $content ) );
575 self::writeLog( '-> errFile: ' . $errFile );
576 self::writeLog( '-> checkFile: ' . $checkFile );
577 self::writeLog( '-> resultFile: ' . $resultFile );
578 self::writeLog( '-> scriptPath: ' . $scriptPath );
579
580 if ( $result !== false && !empty( $result ) ) {
581 $rebuildResult = array();
582 foreach ( $result as $row ) {
583 $row = trim( $row );
584 if ( !empty( $row ) ) {
585 $rebuildResult[] = $row;
586 }
587 }
588 $result = $rebuildResult;
589 self::writeLog( '-> result: ' . substr( implode( ' \\\\ ', $result ), 0, 2048 ) );
590 }
591 else {
592 self::writeLog( '-> result: N/A' );
593 }
594
595 return $result;
596 }
597}
$result
global $bearsamppRoot
global $bearsamppCore
static logError($data, $file=null)
static logDebug($data, $file=null)
static formatUnixPath($path)
__construct()
Definition class.vbs.php:28
static writeLog($log)
Definition class.vbs.php:37
static getResultFile($basename)
static getServiceInfos($serviceName)
static getDefaultBrowser()
Definition class.vbs.php:81
static createShortcut($savePath)
static getInstalledBrowsers()
static getSpecialPath($path)
const STARTUP_PATH
Definition class.vbs.php:25
const ALL_DESKTOP_PATH
Definition class.vbs.php:24
static exec($basename, $resultFile, $content, $timeout=true)
static countFilesFolders($path)
Definition class.vbs.php:50
const DESKTOP_PATH
Definition class.vbs.php:23
const STR_SEPARATOR
Definition class.vbs.php:21
const ALL_STARTUP_PATH
Definition class.vbs.php:26
static killProc($pid)
const END_PROCESS_STR
Definition class.vbs.php:20
static getStartupPath($file=null)
static getListProcs($vbsKeys)
const EXECUTABLE_PATH
const APP_TITLE
Definition root.php:13