Re: log off command




Matija:

I downloaded and installed soon.exe, and put a copy into
c:\windows\system32.

I've tried both the old and the new version of the code (I changed 3600 to
20, so I would not have to wait so long for testing purposes, and I added
two spaces in front of every line that contained text).

Each time I execute the command, a task is generated in taskmanager.
However, user2 is only rarely logged off. I've tried deleting all the tasks
from taskmanager and rebooting, but it still does not work consistently (it
works about 1 out of 10 times, but there is no predictable pattern). When
issuing the command from a cmd window, the following text is displayed:

1

SOON : AT 18:04:45 LOGOFF 1
Added a new job with job ID = 1

Matija, do you have any more ideas? Thanks for your help,

Clem.

"Matija Hrovat" <matija.hrovat@xxxxxxxxxxxxxxx> wrote in message
news:uytI9RJCHHA.4292@xxxxxxxxxxxxxxxxxxxxxxx
CMG,
we did talk about this at the begining of your tread...

You have to download soon.exe:

(http://www.microsoft.com/downloads/details.aspx?familyid=ca8191e6-9eef-4975-b51c-8d670748ca8e&displaylang=en)

or

http://tinyurl.com/wodya

Copy it to c:\windows\system32


Bellow I attached a corrected/shorter version of the code:

++++++++++++++

@echo off
quser %1 >user.txt
for /f "skip=1 tokens=2" %%u in (user.txt) DO SET ID=%%u

ECHO %ID%
SOON 3600 LOGOFF %ID%

del user.txt

++++++++++++++

Let us know if it works now.

Regards,
Matija Hrovat


"C.M.G." <cmg@xxxxxxxxxxxxxxxx> wrote in message
news:OCyZrlDCHHA.3604@xxxxxxxxxxxxxxxxxxxxxxx

Matija,

I did as you suggested, no luck. I ran it form cmd and got this message:

NOT CONSOLE
'SOON' is not recognized as an internal or external command,
operable program or batch file.

Any other ideas?

Clem.

"Matija Hrovat" <matija.hrovat@xxxxxxxxxxxxxxx> wrote in message
news:ezSF4g7BHHA.4680@xxxxxxxxxxxxxxxxxxxxxxx
Hey,
you should also copy quser.exe from c:\windows\system32\dllcache to
c:\windows\system32

Let us know if it works.
If it doesn't try running the script from cmd and look what errors you
get there.

Regards,
Matija Hrovat

"C.M.G." <cmg@xxxxxxxxxxxxxxxx> wrote in message
news:%239Vjfr3BHHA.3928@xxxxxxxxxxxxxxxxxxxxxxx

Matija:

Thanks for writing.

I copied the text into a file that I called logoff.bat. I omitted the
++++ and the blank lines at the beginning and end, and I made sure
there were two blank spaces at the beginning of each line. I did not
change the text in the batch file at all.

I then copied the logoff.bat file to C:\WINDOWS\system32.

I then went to start/run and typed logoff.bat username

For username I used that name that appears in taskmanager under users.

Unfortunately, this has no effect on the other user who is logged on!

Any idea what I am doing wrong?

Thanks again,

Clem.


"Matija Hrovat" <matija.hrovat@xxxxxxxxxxxxxxx> wrote in message
news:O2LQMBsBHHA.3924@xxxxxxxxxxxxxxxxxxxxxxx
Hi CMG,
sorry for a late response.

Save the following code into a .bat file.
+++++++++++

@echo off
quser %1 >user.txt
for /f "skip=1 tokens=2," %%u in (user.txt) DO SET ID=%%u
IF ID==console GOTO CONSOLE

ECHO NOT CONSOLE
SOON 3600 LOGOFF %ID%

GOTO END

:CONSOLE
ECHO IS CONSOLE
SOON 3600 LOGOFF

:END
del user.txt


+++++++++++++
Usage:
Filename.bat username
Every line starts with two spaces so correct the code if they don't.

Let us know if this is what you are looking for.

Regards,
Matija Hrovat


"C.M.G." <cmg@xxxxxxxxxxxxxxxx> wrote in message
news:e1q9tTtAHHA.4256@xxxxxxxxxxxxxxxxxxxxxxx

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
    ... ECHO %ID% ... The quser responses are: ... Each time I execute the command, a task is generated in taskmanager. ... SOON: AT 18:04:45 LOGOFF 1 ...
    (microsoft.public.windowsxp.basics)

Loading