我在月底有一个重复的任务来命令多个远程桌面连接(Win7,Win Server 2008,Win server 2012,Win 8 ......),我需要逐个打开所有这些做这个任务。我想要一些可以登录每一个并发出命令的工具。
这是我试过的:
public Form1()
{
InitializeComponent();
rdp.Server = "1.2.3.4";
rdp.UserName = "Rmlabuser2";
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
secured.ClearTextPassword = "Rmlabuser2";
rdp.Connect();
// open cmd.exe and give commands like VER and return output into a message text box
// rdp.SecuredSettings.StartProgram = @"c:\windows\System32\cmd.exe";
}
完整代码: http://www.codeproject.com/Articles/43705/Remote-Desktop-using-C-NET
任何想法?
感谢。
答案 0 :(得分:0)
You can use psexec to run commands on remote computer.
If you need to run commands within active session, you can create a scheduled task on that computer that will do the needed stuff. Scheduled tasks can be configured to run under currently logged-in session or from system/predefined account.
There are a number of C# libraries that can work with windows scheduled tasks. For example http://taskscheduler.codeplex.com/