基本上,我正在尝试运行在远程机器上复制的批处理文件,顺便说一下,这是我第一次尝试编码,所以请友好,但如果你愿意,请批评它,我还在学习语言和不得不花 3 个小时才能走到这一步,感谢上帝的谷歌,哈哈。
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void cleanerBtn_Click(object sender, EventArgs e)
{
//Copying Batch File to Remote Host
string fileToCopy = "C:\\Clean.bat";
string newLocation = hostName.Text;
string newFile = (newLocation + "\\clean.bat");
System.IO.File.Copy(fileToCopy, newLocation);
//Run PsExec
string psExec = "psexec -s "+newLocation+" cmd";
System.Diagnostics.Process.Start("CMD.exe", psExec);
//Run Batch File using PsExec
//Removing Batch File from Remote Host
System.IO.File.Delete(newFile);
}
}
}
提前致谢。