基本的には、リモート マシンにコピーされたバッチ ファイルを実行しようとしています。ちなみに、コーディングはこれが初めての試みです。よろしければ、お手柔らかにお願いしますが、必要に応じて批評してください。私はまだ言語を学んでおり、ここまで来るのに 3 時間もかかりました。Google のおかげです。LOL。
コード:
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);
}
}
}
前もって感謝します。