我正在编写帮助台应用程序,并希望允许我的用户在远程 PC 上启动远程协助会话。这可以通过 Windows XP 中的帮助来完成,但我无法在 .NET 中找到任何代码示例。谢谢!
Roger
问问题
5790 次
3 回答
4
它实际上非常简单,我写这个是为了让客户下载一个小 exe 并单击一个按钮,它会生成一个远程协助请求票证并在后台打开远程协助。然后文件通过 ftp 和繁荣发送到我的帮助台服务器,我可以一键访问客户端计算机。
只需确保在之后包含递归 kill() ,这样它就不会在后台留下任何挥之不去的进程。
System.Diagnostics.Process p = new System.Diagnostics.Process();
string fileurl = System.IO.Path.GetTempPath() + "Invitation.msrcincident";
p.StartInfo.UseShellExecute = true;
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.StartInfo.FileName = "Msra.exe";
p.StartInfo.Arguments = "/saveasfile " + fileurl + " MyPassword";
Console.WriteLine(p.StartInfo.Arguments);
p.Start();
while (File.Exists(fileurl) == false)
{
Thread.Sleep(1000);
}
//CODE TO EMAIL/UPLOAD FILE HERE
于 2012-11-06T22:13:57.010 回答
1
http://msdn.microsoft.com/en-us/library/ms811079.aspx
您可能需要 P/Invoke 才能实际访问这些功能。
进一步审查后,CodePlex 上有一些来源可以生成远程协助票证。如果我错了,请纠正我,但您希望在客户端生成远程协助票证。查看http://www.codeplex.com/RemoteAssistHelper
于 2009-02-23T20:41:20.343 回答
0
Remote Assistance using the MSRA Exe and its arguments.
Here I have desinged a class and a form, and it gives you the following functionalities,
1) Offer Remote Assistance to a Machine
2) Ask for Remote Help. (Invite someone to help you)
Design A form with the folloiwng controls,
1) Textbox for taking the IP or Computer name to Connect
2) Button 1. To connect to the Remote Machine for offering Remote Assistance
3) Button 2. To Ask or invite someone to help.
Code Behind in the Form:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace RemoteAssist
{
public partial class FrmConnect : Form
{
public FrmConnect()
{
InitializeComponent();
}
private void btnConnect_Click(object sender, EventArgs e)
{
RemoteConnect remoteConnect = new RemoteConnect();
Boolean status;
status = remoteConnect.StartRemoteAssistance(txtComputerName.Text.ToString(), true,false);
if (status == false)
{
System.Windows.Forms.MessageBox.Show("Unable to Connect to the Remote Machine.Please try Again later.");
}
}
private void BtnInvite_Click(object sender, EventArgs e)
{
RemoteConnect remoteConnect = new RemoteConnect();
Boolean status;
status = remoteConnect.StartRemoteAssistance(txtComputerName.Text.ToString(), false, true);
if (status == false)
{
System.Windows.Forms.MessageBox.Show("Unable to Establish Connection, Please try Again later.");
}
}
private void FrmConnect_Load(object sender, EventArgs e)
{
}
private void txtComputerName_TextChanged(object sender, EventArgs e)
{
txtComputerName.CharacterCasing = CharacterCasing.Upper;
}
}
}
We have two buttons here and they are sending the Boolean variable to the class function for differentiating between offer Help and Asking for Help.
Code under the Class File : RemoteConnect
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RemoteAssist
{
class RemoteConnect
{
public Boolean StartRemoteAssistance(String strMachinename, Boolean offerHelp, Boolean askForHelp)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
startInfo.FileName = "msra.exe";
// Offer Remote Assitance
if (offerHelp == true)
{
startInfo.Arguments = "/offerRA " + strMachinename;
}
//ASK for Remote Assistance
if (askForHelp == true)
{
startInfo.Arguments = "novice";
}
try
{
process.StartInfo = startInfo;
process.Start();
return true;
}
catch (Exception ex)
{
//System.Windows.Forms.MessageBox.Show("Error Occured while trying to Connect" + ex.Message);
return false;
}
}
}
}
于 2015-01-23T08:35:31.843 回答