Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string XCopyArguments = """ + dir.FullName + "" "" + destination + "" /D /S /I /E";
- Process XCopyProcess = new Process();
- ProcessStartInfo XCopyStartInfo = new ProcessStartInfo();
- XCopyStartInfo.FileName = "CMD.exe ";
- XCopyStartInfo.RedirectStandardError = true;
- XCopyStartInfo.RedirectStandardOutput = true;
- XCopyStartInfo.RedirectStandardInput = true;
- XCopyStartInfo.UseShellExecute = false;
- XCopyStartInfo.CreateNoWindow = true;
- XCopyStartInfo.Arguments = " /D /c XCOPY " + XCopyArguments;
- XCopyProcess.EnableRaisingEvents = true;
- XCopyProcess.StartInfo = XCopyStartInfo;
- XCopyProcess.Start();
- XCopyProcess.WaitForExit(15000);
- int ExitCode = XCopyProcess.ExitCode;
- if (ExitCode > 0 & !XCopyProcess.HasExited)
- {
- XCopyProcess.Kill();
- }
- XCopyProcess.Dispose();
- Declare Function GenerateConsoleCtrlEvent Lib "kernel32" ( _
- ByVal dwCtrlEvent As Integer, _
- ByVal dwProcessGroupId As Integer _
- ) As Integer
- Private Const CTRL_C_EVENT As Integer = 0
- Private Sub SendCtrlC()
- GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0)
- ' send a Ctrl-C to this process
- GenerateConsoleCtrlEvent(CTRL_C_EVENT, currentpid)
- ' send a Ctrl-C to the cmd process
- GenerateConsoleCtrlEvent(CTRL_C_EVENT, cmdpid)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement