Results 1 to 2 of 2

Thread: How to logoff multiple users logged on Windows Server

  1. #1
    Thor1990 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Apr 2013

    Red face How to logoff multiple users logged on Windows Server

    I want make a Console Application in VB.NET which will logoff all (but not an Administrator) users connectend to Windows 2003 Server machine via RDP Connection.

    I wrote an application which is restarting Server machine, but when there're logged in users, Server got suspended.

    Code of my current application:

    Imports System.IO
    Module Module1
        Sub Main()
            Dim Data As Date = Now 'get actual date and time
            Dim sciezkaPlik As String = "C:\TAI\RestartPC\restartLOG.txt" 'file path
            Dim zapiszDoPliku As New System.IO.StreamWriter(sciezkaPlik, True) 'create a log file
            zapiszDoPliku.WriteLine("Komputer zostanie wyłączony za 60s - " & Data) 'write a message to log file
            zapiszDoPliku.Close() ' close log file
            System.Diagnostics.Process.Start("shutdown", "/r /f /t 60 /d up:0:0") 'force restart Server machine 
                                                                                                  '/r -restart, /f - force close applications, /t 60 - wait 60s, 
                                                                                                  '/d up:0:0 - write to system log message: 'other tasks (scheduled)' 
        End Sub
    End Module
    Can you help me?

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Sydney, Australia
    I'm not aware of a specifically .NET way to do what you want. If I needed to do it myself, I'd look into using the Windows API or WMI.

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts