我正在编写一个帮助台应用程序,并希望允许我的用户在远程PC上启动远程协助会话。这可以通过Windows XP中的帮助来完成,但我在.NET中找不到任何代码示例。谢谢!
发布于 2012-11-07 06:13:57
它实际上非常简单,我写这篇文章是为了允许客户端下载一个小的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发布于 2009-02-23 20:41:20
http://msdn.microsoft.com/en-us/library/ms811079.aspx
您可能需要使用P/Invoke来实际访问这些函数。
在进一步的回顾中,在CodePlex上有一些可以生成远程协助票据的来源。如果我错了,请纠正我,但您希望在客户端生成远程协助的票证。查看http://www.codeplex.com/RemoteAssistHelper
发布于 2015-01-23 16:35:32
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;
}
}
}
}https://stackoverflow.com/questions/579209
复制相似问题