Autor Beitrag
Scofield2011
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55

Windows XP, Windows 7, Windows 8
C#, VBA, VB
BeitragVerfasst: Sa 29.06.13 19:40 
Hallo Leute,

ich habe eine Frage. Und zwar habe ich in einem VBA Projekt den folgenden Code:

ausblenden C#-Quelltext
1:
2:
3:
Shell "net use \\" & IP & "\test /del"1
Shell "net use \\" & IP & "\test /USER:test123 pass123"1
Shell "explorer \\" & IP & "\test\", 1


Gibt es in C# eine Methode, mit der sich ähnlich komfortabel Shell Kommandos ausführen lassen?

Vielen Dank schon einmal im Voraus für eure Hilfe.

Scofield2011
jfheins
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 918
Erhaltene Danke: 158

Win 10
VS 2013, VS2015
BeitragVerfasst: Sa 29.06.13 21:20 
Naja, genau so komfortabel geht es nicht.
Genauer gesagt musst du die cmd.exe manuell aufrufen, wie in dieser SO Frahe gezeigt: stackoverflow.com/qu...ands/1469790#1469790
Um das Konsolenfesnder zu verbergen also:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = @"/C explorer \\" + IP + @"\test\";
process.StartInfo = startInfo;
process.Start();

Das kannst du natürlich relativ einfach in eine Methode kapseln.