我想远程启动一个 Win2k8R2 服务器,Web 版上的程序,它安装了 Windows 服务。
仅当存在“屏幕> 0”时才可能进行服务安装 - 这意味着用户必须登录才能执行此操作(我在某处读到登录对话框窗口代表“屏幕 0”,如果我在这里错了,请纠正我)。因此,为了获得一个屏幕,我打开一个 RDP 连接,然后触发安装程序 exe,它会静默安装所有内容。
我已经让它在 Windows Server 2003 上运行了。在 2008 R2 虽然它不再工作了。我认为可能有一些安全策略,甚至完全是其他技术来实现我想要的。
这是代码:
this.axMsRdpClient7 = new AxMSTSCLib.AxMsRdpClient7();
// ... some GUI stuff happens here..
axMsRdpClient7.Server = hostname;
axMsRdpClient7.UserName = username;
axMsRdpClient7.AdvancedSettings.Compress = -1;
axMsRdpClient7.AdvancedSettings2.DisplayConnectionBar = true;
axMsRdpClient7.AdvancedSettings7.ClearTextPassword = userpassword;
axMsRdpClient7.AdvancedSettings2.EncryptionEnabled = -1;
// Set start program information. vvv THIS IS NOT GOING TO BE EXECUTED vvv
axMsRdpClient7.SecuredSettings.StartProgram = executablePath + " " + arguments;
axMsRdpClient7.SecuredSettings.WorkDir = workingDirectory;
// ... here I'm attaching some events like OnDisconnect...
// Start connection
axMsRdpClient7.Connect();
// Now the startprogram should be executed, but doesn't.
// (at this time its ok that I have to manually log off to reach disconnect. Except you have a better idea to disconnect after startprogram finishes)
while (axMsRdpClient7.Connected != 0)
{
Application.DoEvents();
Thread.Sleep(1);
}
// End connection
axMsRdpClient7.Disconnect();
任何人都知道为什么 StartProgram 没有被执行?我没有任何错误,它只是没有启动。
或者有人知道远程安装服务的更好方法吗?
提前致谢!