private function setValue($key, $subkey, $entry, $value, $type)
 {
     global $neardCore, $neardLang;
     $basename = 'registrySetValue';
     $resultFile = Vbs::getResultFile($basename);
     $this->latestError = null;
     $strKey = $key;
     if ($key == self::HKEY_CLASSES_ROOT) {
         $key = '&H80000000';
     } elseif ($key == self::HKEY_CURRENT_USER) {
         $key = '&H80000001';
     } elseif ($key == self::HKEY_LOCAL_MACHINE) {
         $key = '&H80000002';
     } elseif ($key == self::HKEY_LOCAL_MACHINE) {
         $key = '&H80000003';
     }
     $scriptContent = 'On Error Resume Next' . PHP_EOL;
     $scriptContent .= 'Err.Clear' . PHP_EOL . PHP_EOL;
     $scriptContent .= 'Const HKEY = ' . $key . PHP_EOL . PHP_EOL;
     $scriptContent .= 'Dim objShell, objRegistry, objFso, objFile, outFile, entryValue, newValue' . PHP_EOL . PHP_EOL;
     $scriptContent .= 'newValue = "' . (!empty($value) ? str_replace('"', '""', $value) : '') . '"' . PHP_EOL;
     $scriptContent .= 'outFile = "' . $resultFile . '"' . PHP_EOL;
     $scriptContent .= 'Set objShell = WScript.CreateObject("WScript.Shell")' . PHP_EOL;
     $scriptContent .= 'Set objRegistry = GetObject("winmgmts://./root/default:StdRegProv")' . PHP_EOL;
     $scriptContent .= 'Set objFso = CreateObject("Scripting.FileSystemObject")' . PHP_EOL;
     $scriptContent .= 'Set objFile = objFso.CreateTextFile(outFile, True)' . PHP_EOL . PHP_EOL;
     if (!empty($value)) {
         $scriptContent .= 'objRegistry.' . $type . ' HKEY, "' . $subkey . '", "' . $entry . '", newValue' . PHP_EOL;
     } elseif (!empty($entry)) {
         $scriptContent .= 'objRegistry.' . $type . ' HKEY, "' . $subkey . '", "' . $entry . '"' . PHP_EOL;
     } else {
         $scriptContent .= 'objRegistry.' . $type . ' HKEY, "' . $subkey . '"' . PHP_EOL;
     }
     $scriptContent .= 'If Err.Number <> 0 Then' . PHP_EOL;
     $scriptContent .= '    objFile.Write "' . self::REG_ERROR_ENTRY . '" & Err.Number & ": " & Err.Description' . PHP_EOL;
     $scriptContent .= 'Else' . PHP_EOL;
     if (!empty($value)) {
         $scriptContent .= '    entryValue = objShell.RegRead("' . $strKey . '\\' . $subkey . '\\' . $entry . '")' . PHP_EOL;
         $scriptContent .= '    If entryValue = newValue Then' . PHP_EOL;
         $scriptContent .= '        objFile.Write "' . self::REG_NO_ERROR . '"' . PHP_EOL;
         $scriptContent .= '    Else' . PHP_EOL;
         $scriptContent .= '        objFile.Write "' . self::REG_ERROR_SET . '" & newValue' . PHP_EOL;
         $scriptContent .= '    End If' . PHP_EOL;
     } else {
         $scriptContent .= '    objFile.Write "' . self::REG_NO_ERROR . '"' . PHP_EOL;
     }
     $scriptContent .= 'End If' . PHP_EOL;
     $scriptContent .= 'objFile.Close' . PHP_EOL;
     $result = Vbs::exec($basename, $resultFile, $scriptContent);
     $result = isset($result[0]) ? $result[0] : null;
     if ($subkey == self::ENV_KEY) {
         Batch::refreshEnvVars();
     }
     $this->writeLog('SetValue ' . $strKey . '\\' . $subkey . '\\' . $entry);
     $this->writeLog('-> value: ' . $value);
     $this->writeLog('-> result: ' . $result);
     if (Util::startWith($result, self::REG_ERROR_SET)) {
         $this->latestError = sprintf($neardLang->getValue(Lang::REGISTRY_SET_ERROR_TEXT), str_replace(self::REG_ERROR_SET, '', $result));
         return false;
     } elseif (Util::startWith($result, self::REG_ERROR_ENTRY)) {
         $this->latestError = $neardLang->getValue(Lang::ERROR) . ' ' . str_replace(self::REG_ERROR_ENTRY, '', $result);
         return false;
     }
     return $result == self::REG_NO_ERROR;
 }