1 Using System;
2 Using System. Collections. Generic;
3 Using System. LINQ;
4 Using System. text;
5 Using System. Threading;
6 Using System. diagnostics;
7
8 Namespace Leleapplication1
9 {
10 Class Command
11 {
12 Public Static String Startcmd ( String Command)
13 {
14 String Output = "" ;
15 Try
16 {
17
18 Process cmd = New Process ();
19 Cmd. startinfo. filename = command;
20
21 Cmd. startinfo. useshellexecute = False ;
22
23 Cmd. startinfo. redirectstandardinput = True ;
24 Cmd. startinfo. redirectstandardoutput = True ;
25
26 Cmd. startinfo. createnowindow = True ;
27 Cmd. startinfo. windowstyle = processwindowstyle. hidden;
28
29 Cmd. Start ();
30
31 Output = cmd. standardoutput. readtoend ();
32 Console. writeline (output );
33 Cmd. waitforexit ();
34 Cmd. Close ();
35 }
36 Catch (Exception E)
37 {
38 Console. writeline (E );
39 }
40 Return Output;
41 }
42 Public Static String Startcmd (String Command, String Argument)
43 {
44 String Output = "" ;
45 Try
46 {
47 Process cmd = New Process ();
48
49 Cmd. startinfo. filename = command;
50 Cmd. startinfo. Arguments = argument;
51
52 Cmd. startinfo. useshellexecute = False ;
53
54 Cmd. startinfo. redirectstandardinput = True ;
55 Cmd. startinfo. redirectstandardoutput =True ;
56
57 Cmd. startinfo. createnowindow = True ;
58 Cmd. startinfo. windowstyle = processwindowstyle. hidden;
59
60 Cmd. Start ();
61
62 Output = cmd. standardoutput. readtoend ();
63 Console. writeline (output );
64 Cmd. waitforexit ();
65 Cmd. Close ();
66 }
67 Catch (Exception E)
68 {
69 Console. writeline (E );
70 }
71 Return Output;
72 }
73 }
74 }