[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

SLN

11/18/2002 4:52:00 PM

I need to log out the user of the workstation
upon specific conditions.

What is the .NET framework method/function that
will allow me to do this?


4 Answers

elziko

11/18/2002 5:43:00 PM

0

Give this lot a go:

Public Enum ShutDownTypes
LogOff = 0
ForcedLogOff = 4
Shutdown = 1
ForcedShutdown = 5
Reboot = 2
ForcedReboot = 6
PowerOff = 8
ForcedPowerOff = 12
End Enum

Public Sub Shutdown(ByVal ShutDownType As ShutDownTypes)
Dim Connection, WQL, SystemClass, System
Connection =
GetObject("winmgmts:{impersonationLevel=impersonate,(ShutDown)}")
WQL = "Select Name From Win32_OperatingSystem"
SystemClass = Connection.ExecQuery(WQL)
For Each System In SystemClass
System.Win32ShutDown(ShutDownType)
Next
End Sub

HTH,

elziko


SLN

11/18/2002 7:45:00 PM

0

Elziko,

Thanks for the solution. That worked perfectly.

sln

"elziko" <elziko@NOTSPAMMINGyahoo.co.uk> wrote in message
news:uRy6iGyjCHA.2772@tkmsftngp10...
> Give this lot a go:
>
> Public Enum ShutDownTypes
> LogOff = 0
> ForcedLogOff = 4
> Shutdown = 1
> ForcedShutdown = 5
> Reboot = 2
> ForcedReboot = 6
> PowerOff = 8
> ForcedPowerOff = 12
> End Enum
>
> Public Sub Shutdown(ByVal ShutDownType As ShutDownTypes)
> Dim Connection, WQL, SystemClass, System
> Connection =
> GetObject("winmgmts:{impersonationLevel=impersonate,(ShutDown)}")
> WQL = "Select Name From Win32_OperatingSystem"
> SystemClass = Connection.ExecQuery(WQL)
> For Each System In SystemClass
> System.Win32ShutDown(ShutDownType)
> Next
> End Sub
>
> HTH,
>
> elziko
>
>


ebycook

11/19/2002 12:33:00 AM

0

stupid side note... in WinNT5 spawn the logoff process. it's less coding.

dim p1 as new Process()
p1.StartInfo.FileName = "logoff"
p1.Start()
'<snip>

Andrew Cook

"sln" <solutions@portaltech.com> wrote in message
news:ebxBlKzjCHA.1652@tkmsftngp11...
> Elziko,
>
> Thanks for the solution. That worked perfectly.
>
> sln
>
> "elziko" <elziko@NOTSPAMMINGyahoo.co.uk> wrote in message
> news:uRy6iGyjCHA.2772@tkmsftngp10...
> > Give this lot a go:
> >
> > Public Enum ShutDownTypes
> > LogOff = 0
> > ForcedLogOff = 4
> > Shutdown = 1
> > ForcedShutdown = 5
> > Reboot = 2
> > ForcedReboot = 6
> > PowerOff = 8
> > ForcedPowerOff = 12
> > End Enum
> >
> > Public Sub Shutdown(ByVal ShutDownType As ShutDownTypes)
> > Dim Connection, WQL, SystemClass, System
> > Connection =
> > GetObject("winmgmts:{impersonationLevel=impersonate,(ShutDown)}")
> > WQL = "Select Name From Win32_OperatingSystem"
> > SystemClass = Connection.ExecQuery(WQL)
> > For Each System In SystemClass
> > System.Win32ShutDown(ShutDownType)
> > Next
> > End Sub
> >
> > HTH,
> >
> > elziko
> >
> >
>
>


Kev Sherratt

12/16/2002 5:22:00 PM

0

Good grief. No, please, don't ever do this kind of
thing. Unless you want to open up your system to all
sorts of potential security breaches, this is a really
daft thing to do.

You can exploit a similar trick commonly used in Unix
shell script programming. As a simple example, create a
file (logoff.bat) in the same folder as you're running
the code below from. In this batch file, put something
like "explorer.exe". Save this and run your program.
Watch in wonder as a new version of Windows Explorer pops
up on your screen. This in turn depends on which program
named "explorer.exe" it finds in your path first.

Silly example, but if it were a more malicious trojan,
you could end up with some serious trouble on your
hands. Especially if you run with any elevated
privileges.

Just say no! Do it properly, or don't do it at all.

K.

>-----Original Message-----
>stupid side note... in WinNT5 spawn the logoff process.
it's less coding.
>
>dim p1 as new Process()
>p1.StartInfo.FileName = "logoff"
>p1.Start()
>'<snip>