기본적으로 원격 컴퓨터에 복사 된 배치 파일을 실행하려고하는데, 이것은 코딩의 첫 번째 시도이므로 좋을하시기 바랍니다. 그러나 비판을 원한다면, 나는 아직도 언어를 배우고 있으며, 이것을 얻기까지 3 시간을 소비해야만한다. 구글, 롤 (LOL)에게 감사한다.PsExec 시작된 후 원격 컴퓨터에서 C# 실행중인 배치 파일
코드 : 사전에
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);
}
}
}
감사합니다.
일을 좋은 태도 :
은 기본적으로 당신이 할 싶어요. 내가 당신을 도울 수 있도록 psexec을 알았 으면 좋겠어요. –
스타일 제안 : 상단에'using SystemDiagnostics;'와'using System.IO;'를 추가하고'Process.Start ("CMD.exe", psExec);','File.Copy (fileToCopy, newLocation); "File.Delete (newFile);'이후에. – joce
그것에 관한 어떤 해결책이 있나요? – Kiquenet