how to make other client macine to log off

pksucks

New member
Joined
Sep 18, 2009
Messages
2
Programming Experience
Beginner
In a client server enviornment, how to make other system(client) log off using programming statement written in .net ? i am developing an application which will control the log off of other systems. should i use some windows API ?
 
Depending on your application, you could send data (how ever you are transferring commands), such as a string saying: "Log Off Computer"

Depending on the mechanism you are using, you should then be able to check for the arrival of information, and if a string arrives that = "Log Off Computer" then it should run this bit of code:
VB.NET:
System.Diagnostics.Process.Start("shutdown", "-l -t 00")

The entire code should then look something similar of this (for the client)

VB.NET:
    Private Sub On Stringreceived (depending on how you are sending the data)
    Dim NewInformation = Received String
        If NewInformation = "Log Off Computer" Then
            System.Diagnostics.Process.Start("shutdown", "-l -t 00")
        End If
    End Sub

Hope this helps

Also, you can shut down and restart using a very similar code:

VB.NET:
rivate Sub btnShutdown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShutdown.Click
        System.Diagnostics.Process.Start("shutdown", "-s -t 00")
        'This will make the computer Shutdown
    End Sub

    Private Sub btnRestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestart.Click
        System.Diagnostics.Process.Start("shutdown", "-r -t 00")
        'This will make the computer Restart
    End Sub

    Private Sub btnLogOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogOff.Click
        System.Diagnostics.Process.Start("shutdown", "-l -t 00")
        'This will make the computer Log Off
    End Sub
 
Last edited:
Hey, can you please reply on the main thread, so others can benefit from the information too :)

Ok, first im asumming you may want to make this application invisible?
so you would start using a code to make it invisible:

VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Hide()
        Me.ShowInTaskbar = False
    End Sub


You then have several options to tell the client computers (say you have three - 1, 2, 3) when the time has started, and when their time has finished (You may want to put a timer in the bottom corner or something so the user knows how much time has elapsed, or is remaining)

Methods of telling the computer to turn off could include: eMail or WinSock.

Sorry, but im not really sure how to use WinSock in vb2005 or 2008, so i cant help much there, and i know how to send emails, but not receive them, although i am sure there are some other people on this forum that are more experienced than me, and would be able to tell you how to send packets over a network, or directly over the internet.

Now, on the sever side (mainframe computer), You should time how long each user is online, so when a new user buys time, you click a button, with a time in a text box, and it starts counting down (or up). You could do this by using a timer that ticks every second, and a i = i + 1 function. or in your case it would be a User1Time = User1Time + (or - 1) depending on the time that they have chosen. If you want an app that counts in minutes, i will upload it if you request.

So if you have any more questions about how to structure the program on either end, but i am not completly sure as to getting the information across the computers.

Hope this helps :)

HaXarO
 
Back
Top