private void InstallVNC(string msifullpath,string password="vdsm")
{
try
{
string serviceName = "tvnserver";
ServiceController[] services = ServiceController.GetServices();
bool serviceExists = services.Any(s => s.ServiceName == serviceName);
if (serviceExists)
{
WriteTipInfo("远程服务已存在,跳过自动部署!", Color.Blue);
}
else
{
WriteTipInfo("远程服务未安装,即将自动部署", Color.Blue);
string cmd = string.Format("msiexec.exe /i \"{0}\" /norestart /qn SET_USEVNCAUTHENTICATION=1 VALUE_OF_USEVNCAUTHENTICATION=1 SET_PASSWORD=1 VALUE_OF_PASSWORD={1} SET_VIEWONLYPASSWORD=1 VALUE_OF_VIEWONLYPASSWORD={1} SET_USECONTROLAUTHENTICATION=1 VALUE_OF_USECONTROLAUTHENTICATION=1 SET_CONTROLPASSWORD=1 VALUE_OF_CONTROLPASSWORD={1} SET_RUNCONTROLINTERFACE=1 VALUE_OF_RUNCONTROLINTERFACE=0", msifullpath, password);
File.WriteAllText("InsertRemote.bat", cmd);
Process.Start("InsertRemote.bat");
WriteTipInfo("远程服务的执行自动安装完成!", Color.Blue);
}
}
catch (Exception err)
{
WriteTipInfo("远程服务自动安装过程出现异常:"+err.Message, Color.Red);
}
}
各安装配置命令见PDF:https://www.tightvnc.com/doc/win/TightVNC_2.7_for_Windows_Installing_from_MSI_Packages.pdf