Re: log off command




Dear Matija,

Thanks for your comprehensive answer!

I downloaded psshutdown.exe, but I cannot make it do what I am trying to
achieve:

I have two users on my local machine. I would like to log off user2, but not
user1, 60 minutes after issuing the command, and I want the logoff to force
running applications under user2 to close. I do not want to shutdown the
computer, and I do not want to log off user1, or stop applications running
under user1.

Matija, do you think you could help me with the syntax for that command?

Thanks again,

Clem.


"Matija Hrovat" <matija.hrovat@xxxxxxxxxxxxxxx> wrote in message
news:eTCbucZAHHA.3396@xxxxxxxxxxxxxxxxxxxxxxx
Hi C.M.G,
there are two (well at least two) possibilities.
One is using the command you mentioned "shutdown"
and the other is using a free Sysinternals utility: PsShutdown
(http://www.sysinternals.com/Utilities/PsShutdown.html).

The main problem with both utilities is the timeout.
I am almost sure that there is no way to set the logoff timeout with
shutdown (there is supposed to be a way in earlier versions of shutdown,
but I didn't find it) and I could not find a way to "persuade" the
PsShutdown to use the timeout switch with the logoff switch.


So I propose that you use the "at" command to set the time;

The whole command should look something like this:
at 21:00 /interactive /every:M,T,W,Th,F shutdown -l -f

The command will log off a user ever weekday at 9 pm.


The other way to go is with the "soon.exe" utility which you can download
from the following link:

(http://www.microsoft.com/downloads/details.aspx?familyid=ca8191e6-9eef-4975-b51c-8d670748ca8e&displaylang=en)
With "soon" you can set the amount of time after a specific command will
execute.
e.g.
soon /interactive 3600 shutdown -l -f

The command will log off a user after 3600 seconds.


Of course there is a lot of different ways to logoff a user using a
command line or a script. If you are familiar with vbs scripts you can
create that or you can use one of the 3rd party utilities (e.g.
http://www.robvanderwoude.com/shutdown.html) that do exactly what you
want.


VBS Example:
'---Start Script
Const LOGOFF = 0
Const SHUTDOWN = 1
Const REBOOT = 2
Const fLOGOFF = 4
Const fSHUTDOWN = 5
Const fREBOOT = 6

strComputer = "."
Set objWMIService = GetObject _
("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _
strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
Wscript.Sleep 5000
objOperatingSystem.Win32Shutdown(fLOGOFF)
Next

'----End Script

The user will be logged off after 5 seconds.


I hope the mentioned helps and please let us know if this is the
information you were looking for and let me know if anything is unclear in
the post.

Regards,
Matija Hrovat





"C.M.G." <cmg@xxxxxxxxxxxxxxxx> wrote in message
news:eARse44$GHA.3536@xxxxxxxxxxxxxxxxxxxxxxx

To clarify my question below: I am looking for a command or script to log
off another specific user at a specific time, rather than shutting off
the whole computer.

Thanks for your help.

Clem.

"C.M.G." <cmg@xxxxxxxxxxxxxxxx> wrote in message
news:ehx%23$5v%23GHA.1224@xxxxxxxxxxxxxxxxxxxxxxx

I use the following command in a batchfile to force shutdown of my
computer 60 minutes after issuing the command, and to reboot the
computer:

shutdown -r -f -t 3600

My question is: is there a command to log off another user a certain
time after the command is issued, and force logoff of that user?

Thank you,

Clem.







.



Relevant Pages

  • Re: log off command
    ... Matija Hrovat ... Each time I execute the command, a task is generated in taskmanager. ... SOON: AT 18:04:45 LOGOFF 1 ... Const SHUTDOWN = 1 ...
    (microsoft.public.windowsxp.basics)
  • Re: log off command
    ... Matija Hrovat ... Each time I execute the command, a task is generated in taskmanager. ... SOON: AT 18:04:45 LOGOFF 1 ... Const SHUTDOWN = 1 ...
    (microsoft.public.windowsxp.basics)
  • Re: log off command
    ... SOON 3600 LOGOFF %ID% ... 'SOON' is not recognized as an internal or external command, ... One is using the command you mentioned "shutdown" ... Const SHUTDOWN = 1 ...
    (microsoft.public.windowsxp.basics)
  • Re: log off command
    ... Matija Hrovat ... Each time I execute the command, a task is generated in taskmanager. ... SOON: AT 18:04:45 LOGOFF 1 ... Const SHUTDOWN = 1 ...
    (microsoft.public.windowsxp.basics)
  • Re: log off command
    ... Each time I execute the command, a task is generated in taskmanager. ... SOON: AT 18:04:45 LOGOFF 1 ... You have to download soon.exe: ... Const SHUTDOWN = 1 ...
    (microsoft.public.windowsxp.basics)