Question How to logoff multiple users logged on Windows Server

Thor1990

Member
Joined
Apr 8, 2013
Messages
7
Programming Experience
Beginner
Hi,
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:

Code:
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? :joyous:
 
Top Bottom