|
@ -74,25 +74,33 @@ function officeInfo(): array { // office dir and kms key for different version |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function officeCommand(string $dir, string $key, string $host): string { // load office active command |
|
|
function officeCommand(string $dir, string $key, string $host, int $port): string { // load office active command |
|
|
$command = 'if exist "%ProgramFiles%\Microsoft Office\\' . $dir . '\ospp.vbs" '; |
|
|
$command = 'if exist "%ProgramFiles%\Microsoft Office\\' . $dir . '\ospp.vbs" '; |
|
|
$command .= 'cd /d "%ProgramFiles%\Microsoft Office\\' . $dir . "\"\n"; |
|
|
$command .= 'cd /d "%ProgramFiles%\Microsoft Office\\' . $dir . "\"\n"; |
|
|
$command .= 'if exist "%ProgramFiles(x86)%\Microsoft Office\\' . $dir . '\ospp.vbs" '; |
|
|
$command .= 'if exist "%ProgramFiles(x86)%\Microsoft Office\\' . $dir . '\ospp.vbs" '; |
|
|
$command .= 'cd /d "%ProgramFiles(x86)%\Microsoft Office\\' . $dir . "\"\n"; |
|
|
$command .= 'cd /d "%ProgramFiles(x86)%\Microsoft Office\\' . $dir . "\"\n"; |
|
|
$command .= "cscript ospp.vbs /inpkey:$key\n"; |
|
|
$command .= "cscript ospp.vbs /inpkey:$key\n"; |
|
|
$command .= "cscript ospp.vbs /sethst:$host\n"; |
|
|
$command .= "cscript ospp.vbs /sethst:$host\n"; |
|
|
|
|
|
if ($port != 1688) { |
|
|
|
|
|
$command .= "cscript ospp.vbs /setprt:$port\n"; |
|
|
|
|
|
} |
|
|
$command .= "cscript ospp.vbs /act\n"; |
|
|
$command .= "cscript ospp.vbs /act\n"; |
|
|
return $command . "cscript ospp.vbs /dstatus\n"; |
|
|
return $command . "cscript ospp.vbs /dstatus\n"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function osppCommand(string $host): array { // load office ospp command |
|
|
function osppCommand(string $host, int $port): array { // load office ospp command |
|
|
return array( |
|
|
$osppCmd = array( |
|
|
'/dstatus' => ['Displays license information for installed product keys.', '显示当前已安装产品密钥的许可证信息'], |
|
|
'/dstatus' => ['Display license information for installed product keys.', '显示当前已安装产品密钥的许可证信息'], |
|
|
'/dstatusall' => ['Displays license information for all installed licenses.', '显示当前已安装的所有许可证信息'], |
|
|
'/dstatusall' => ['Display license information for installed licenses.', '显示当前已安装的所有许可证信息'], |
|
|
'/unpkey:XXXXX' => ['Uninstalls an product key with the last five digits of it.', '卸载已安装的产品密钥(最后5位)'], |
|
|
'/unpkey:XXXXX' => ['Uninstall a product key with the last five digits of it.', '卸载已安装的产品密钥(最后5位)'], |
|
|
'/inpkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX' => ['Installs a product key with a user-provided product key.', '安装产品密钥'], |
|
|
'/inpkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX' => ['Install a product key with user-provided product key.', '安装产品密钥'], |
|
|
"/sethst:$host" => ['Sets a KMS host name with a user-provided host name.', '设置 KMS 主机名'], |
|
|
"/sethst:$host" => ['Set a KMS host name with user-provided host name.', '设置 KMS 主机名'], |
|
|
'/remhst' => ['Removes KMS host name and sets port to default.', '删除 KMS 主机名'], |
|
|
"/setprt:$port" => ['Set a KMS port with user-provided port number.', '设置 KMS 主机端口'], |
|
|
'/act' => ['Activates installed Office product keys.', '激活 Office'], |
|
|
'/remhst' => ['Remove KMS host name and sets port to default.', '删除 KMS 主机名'], |
|
|
|
|
|
'/act' => ['Activate installedOffice product keys.', '激活 Office'], |
|
|
); |
|
|
); |
|
|
|
|
|
if ($port == 1688) { |
|
|
|
|
|
unset($osppCmd["/setprt:$port"]); // remove setprt option with default port |
|
|
|
|
|
} |
|
|
|
|
|
return $osppCmd; |
|
|
} |
|
|
} |
|
|