Closed KoalafiedDev closed 2 years ago
Rather than parse the output, have you tried looking at the return code? On Linux, at least, vlmcs returns a non-zero exit code when it encounters an error.
Also, why is the workstation name ns1.microsoft.com.tw? Do you work for Microsoft?? 😅
Thanks for your reply. The return code is a great tip. Although I can't directly see what the error code means, I know that an error occurred and that is enough. I applied the solution in the code below.
public static string vlmcs(string server, string port)
{
Cursor.Current = Cursors.AppStarting;
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "vlmcs-Windows-x64.exe",
Arguments = $"{server}:{port} -v",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
Cursor.Current = Cursors.Default;
if (proc.ExitCode != 0)
{
output = output + "Fatal: Could not connect to any KMS server";
}
return output;
}
And btw no, I do not work for Microsoft 😂. This is a test request performed by vlmcs to test the connection to the kms server lol.
Glad it was a helpful tip. Unfortunately, the error handling code (and other types of code) in vlmcs and vlmcsd is all over the place, so it's kind of a pain to map all possible return codes out... unless they are documented in the man pages? But I doubt that.
When using the command:
START "" /WAIT /b "%~dp0vlmcs-Windows-x64.exe" 192.168.2.14 -v
the output is missing information when the kms server cannot be contacted.for example; when the kms server can't be contacted, the output from cmd is:
but the error part is missing from the output:
I know that I can use the
Pause
orTimeout /t
command, but I'm trying to pass the output to a C# application, and I can't get it to work. Is there a solution for this?