我想在安装Windows服务的Win2k8R2服务器Web版上远程启动一个程序。Windows Server 2008 R2远程服务安装:如何在C#之后的RDP连接之后执行程序?
服务安装只有在“屏幕> 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中?我没有任何错误,它只是不启动。
或者任何人都知道更好的方法来远程安装服务?
在此先感谢!