Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

CMD Befehl query session wird nicht über das C#Programm erkannt

Empfohlene Antworten

Veröffentlicht

Hallöchen,

ich würde gerne über das C#-Prgramm den Befehl query session ausführen.

Der Befehl wird aber dann in der Konsole nicht erkannt.

Starte ich die Eingabeauffprderung direkt aus Windows und gebe den Befehl manuell ein, wird dieser problemlos ausgeführt.

Auch eine Batch-Datei mit diesem Inhalt wird nicht über das c#-Programm ausgeführt, manuell jedoch schon.

  public void btn7_Click(object sender, RoutedEventArgs e)
        {

            Process p = new Process();
            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.FileName = "cmd.exe"
            startInfo.Verb = "runas";
            //startInfo.Arguments = @"/k " + "query session";
            p.StartInfo = startInfo;
            p.Start();
        }

 

Viele Grüße und danke im voraus :)

Ich habe mal  die Antwort des Stackoverflow Artikels  getestet:

Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c dir *.cs";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();

string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();

Console.WriteLine("Output:");
Console.WriteLine(output);    

Das scheint zu funktionieren.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.