olmeca3332003
(Fresh Scripter)
2004-01-15 01:22 AM
Logoff all users

Greetings to all
We are experiencing large amount of our users are not logging off at the end of their workday, hence bypassing the login script. Is it possible to logoff any lock workstations after x hour of inactivity daily? Any and all suggestions are welcome.


NTDOCAdministrator
(KiX Master)
2004-01-15 02:11 AM
Re: Logoff all users

Please let us know what Server and Desktop environment you are in and what version of KiXtart you use.

Server NT 4 model or 2000/2003 AD model?
Clients Win9x/2K/XP or mix?

Are you looking for a SOLUTION or a FREE work-around to the issue via some automated method?


olmeca3332003
(Fresh Scripter)
2004-01-15 03:26 AM
Re: Logoff all users

I’m currently using kixtart ver 4.22 and we operate in an NT4 server environment with mix client-nt,w2k and xp. I was looking forward to the start of a script that checks for inactivity while counting and reset if activity is detected.

LonkeroAdministrator
(KiX Master Guru)
2004-01-15 05:35 AM
Re: Logoff all users

I remember I asked for com-automation piece for that and remember talking to some of our com-dll-ppl but don't remember did they provide me an interface for that (sadly, was too dwelled with work-related-stress)

anyway, basically it's not possible but with compiled proggies, yet once it's available via dll, it is doable.
as can't remember where that dll thing stopped, I have to say you can't do such thing.

basically, all you need is to query from OS for the kb and mice idle-time.


Co
(MM club member)
2004-01-15 08:47 AM
Re: Logoff all users

create a logoff script and schedule it.

For XP this isn't a problem because you can use schtasks:
Quote:


SCHTASKS /Create [/S system [/U username [/P password]]]
[/RU username [/RP password]] /SC schedule [/MO modifier] [/D day]
[/I idletime] /TN taskname /TR taskrun [/ST starttime] [/M months]
[/SD startdate] [/ED enddate]


/I idletime Specifies the amount of idle time to
wait before running a scheduled
ONIDLE task.
Valid range: 1 - 999 minutes.





For the other os's you have to use something else.

It isn't freeware but maybe this can help you:
http://www.ayesoftware.com/asd/products.php

I'll let you know if there is something else you can use..


Co
(MM club member)
2004-01-15 09:15 AM
Re: Logoff all users

I think JT.exe can do the job..

Take a look at this UDF:
TaskScheduleControl() - Library of UDFs to manage Windows Task

A few other URLS:

http://www.jsiinc.com/SUBF/TIP2600/rh2621.htm

http://msdn.microsoft.com/library/en-us/taskschd/taskschd/task_scheduler_start_page.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/taskschd/taskschd/ischeduledworkitem_setidlewait.asp

http://www.nncron.ru/





MightyR1
(MM club member)
2004-01-15 09:16 AM
Re: Logoff all users

Or if all users must have left the building at 18:00, start a script at logon which checks the time every 15 min. and if time > 18:00 do a shutdown.

Co
(MM club member)
2004-01-15 09:43 AM
Re: Logoff all users

When they don't logoff it will not start at logon... it is better to schedule a task. Of course you can schedule a shutdown at 19:00

LonkeroAdministrator
(KiX Master Guru)
2004-01-15 11:01 AM
Re: Logoff all users

well, my co-worker did a task that kills all CAD proggies at the factory every 15min or so.
your plans start to sound just like that.

why don't you connect the power-outlets of the offices to the lightswitch?
when dude leaves or guards turns the lights off, byu byu left-on comps.


AzzerShaw
(Seasoned Scripter)
2004-01-15 01:21 PM
Re: Logoff all users

I use shutdown via scheduled task. This also helps with a virtual memory problems etc Admittley you get "peeved" users moaning that they didnt save there work but thats there on stoopid fault !!! And they are allowed to be laughed at

Richie19Rich77
(Seasoned Scripter)
2004-01-15 02:35 PM
Re: Logoff all users

All my users use a Mandatory Profile, with a logoff screensaver set for 20 minutes.

This seems to do the trick.


Sealeopard
(KiX Master)
2004-01-15 03:29 PM
Re: Logoff all users

Why not just limit the permitted logon hours for users with automatic logoff? This feature has been present in Windows since at least the NT4 domain model. See HOW TO: Limit User Logon Time in a Domain in Windows 2000, HOW TO: Limit User Logon Time in a Domain in Windows Server 2003, and How to limit a user's login hours on Windows NT

Wizard
(Hey THIS is FUN)
2004-01-16 08:54 AM
Re: Logoff all users

Using logon hours in this way might not be possible if remote users dial in after hours.

LonkeroAdministrator
(KiX Master Guru)
2004-01-16 09:00 AM
Re: Logoff all users

well, you can keep a list of users who have a habit to leave themselfes locked on.
I know from our corp that many do leave it like that but there is also some that do it because they will come back to office when everyone else is gone.
for the others you feel leave themselfes locked on for no reason, start setting their profiles.

anyway, to force a daily logon, woah...
there should no need for that. if you have a logonscript that needs to run daily... well, you should start building an admin script.


Co
(MM club member)
2004-01-16 11:32 AM
Re: Logoff all users

Then schedule this admin script and let it start when idletime is X.... Users don't have to logoff


P.s. I also never logoff my system


LonkeroAdministrator
(KiX Master Guru)
2004-01-16 12:05 PM
Re: Logoff all users

I think the main thing with this bloody schedule-discussion started from my comments saying that can't look at idle time with kix.
that is, without any help of other proggies.


Co
(MM club member)
2004-01-16 12:19 PM
Re: Logoff all users

true, but XP has a buildin proggie... schtasks... and jt.exe is used a lot in kix scripts/udf's So...

LonkeroAdministrator
(KiX Master Guru)
2004-01-16 01:07 PM
Re: Logoff all users

heh, XP.
it has nothing to do with current task as it's only part of the targets that have it installed.


Co
(MM club member)
2004-01-16 02:06 PM
Re: Logoff all users

How do I use Schtasks.exe to schedule tasks in Windows Server 2003?
Your own (very nice) UDF library - TaskScheduleControl() - Library of UDFs to manage Windows Task Scheduler

Tell me why you can't schedule a task on a target computer which have to start after X idletime... Maybe you cann't use schtasks but jt shouldn't be a problem..


LonkeroAdministrator
(KiX Master Guru)
2004-01-16 04:10 PM
Re: Logoff all users

the problem is that you can't see remotely the idle-time.

Chris S.
(MM club member)
2004-01-16 04:31 PM
Re: Logoff all users

The problem is more insidious than that, even. What if a computer is left on to perform a scheduled task (example, I have a client here with a scheduled FTP task to download a file from a customer every night)? The scheduled task operation would never record any "non-idle" time, as no user input would occur. Additionally, it would be a mere blip on CPU cycles as well.

Co
(MM club member)
2004-01-16 06:35 PM
Re: Logoff all users

Chris,

I agree, this is a possible problem... but if you want, you can schedule a task on a remote computer which starts after x idle time... the remote computer can see its owns idle time...

Basta!


Chris S.
(MM club member)
2004-01-16 07:53 PM
Re: Logoff all users

I think the confusion may be "idle-time." Idle-time is lack of user input, either through the mouse or the keyboard. It isn't necessarily CPU cycles. I believe, and correct me if I'm wrong, that this is what Task Scheduler uses to determine idle-time.

Co
(MM club member)
2004-01-16 10:23 PM
Re: Logoff all users

MMM,

Sorry Chris, I was a bit irritated about Lonkero's replies... You are right about the idle time but In this case "idle" must be a lack of user input..

Quote:


Platform SDK: Task Scheduler

Idle Triggers
An idle trigger is an event-based trigger that is fired a specific amount of time after the computer becomes idle. The computer is considered to be in an idle state when no keyboard or mouse input occurs.





The question is:
Quote:


...We are experiencing large amount of our users are not logging off at the end of their workday, hence bypassing the login script. Is it possible to logoff any lock workstations after x hour of inactivity daily?...





This means you can use task scheduler and idletime. Lets say a workday + 1 hour = idletime. (If idletime < difference between end and beginning workday)


schtasks:
Quote:


Syntax
schtasks /create /tn TaskName /tr TaskRun /sc onidle /i {1 - 999} [/sd StartDate] [/it] [/ru {Domain\]User [/rp Password] | System}] [/s Computer [/u [Domain\]User [/p Password]]]

Remarks
The "on idle" schedule type schedules a task that runs whenever there is no user activity during the time specified by the /i parameter. In the "on idle" schedule type, the /sc onidle parameter and the /i parameter are required. The /sd (start date) is optional and the default is the current date.

Examples
To schedule a task that runs whenever the computer is idle
The following command schedules the MyApp program to run whenever the computer is idle. It uses the required /i parameter to specify that the computer must remain idle for ten minutes before the task starts.

schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc onidle /i 10







LonkeroAdministrator
(KiX Master Guru)
2004-01-17 01:30 AM
Re: Logoff all users

hey, me irritating?
I'm only pissing you off... that's no bad...

ja, sure you can do remote.
and yes, the remote machine can see it's own idle time.
but my hit was, does your command line tool also support older windows clients.
cause sure they don't have same version of task scheduler.


Co
(MM club member)
2004-01-17 12:40 PM
Re: Logoff all users

Quote:


we operate in an NT4 server environment with mix client-nt,w2k and xp





So like I said more than once... Jt.exe can do this job...
How many times do I have to say this before you get it???

Quote:


Appendix: How to Install Task Scheduler
a. Windows 98 and Windows 2000/XP:

Nothing to do ! The task scheduler is already preinstalled on your Windows system !

b. Windows 95

On Win 95 / NT the task scheduler is not preinstalled, but you can easily install Task Scheduler through Internet Explorer 4.0 or higher. To install Task Scheduler under Windows 95, proceed as if running Windows NT4 (see below). Note: Windows 95 Plus! contains a product called System Agent. This is not the same product.

c. Windows NT4 (SP3+)

Go to the Control Panel and select Add/Remove Programs. Select Microsoft Internet Explorer 4 or 5 from the list, and when a dialog prompt you for what to do, select Add a component. Depending on the current release of your browser (4 or 5), you will eventually be given a list of additional software
you may install (Note: this may take a long time!). With IE4 you should select Task Scheduler under Additional Explorer Enhancements. With IE5 select the Offline Browsing Pack. You can also go directly to <http://www.microsoft.com/windows/ie>. From here you can select all IE software releases and add-ons. We recommend you upgrade to IE5. We've had a lot of problems reported about upgrading IE4, you would probably be better off installing IE5 anyway (it's a much better
browser). Click Yes to restart your computer when prompted.

Remark: If you are a Netscape supporter, do not worry: It is not necessary to install the shell integration component or or use Internet Explorer as your your default browser for the task scheduler to work. The task scheduler is a (more or less) independent piece of software that just happened to be be distributed via the Internet Explorer packages.






LonkeroAdministrator
(KiX Master Guru)
2004-01-17 03:29 PM
Re: Logoff all users

ja, you said.
but none of the documents I've read (and one of you just made a quote) do say it.


Co
(MM club member)
2004-01-17 04:09 PM
Re: Logoff all users

It is getting funny now...

Ok, it doesn't say JT.EXE can do the job but is says you can use Windows XP, Windows 2000 Professional, Windows Me, and Windows 98 and NT4/sp3 with =/>IE4 .

Platform SDK: Task Scheduler IScheduledWorkItem::SetFlags

Quote:


Requirements
Client: Requires Windows XP, Windows 2000 Professional, Windows Me, and Windows 98.
Server: Requires Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Internet Explorer 4.0 or later on Windows NT 4.0 and Windows 95.
Header: Declared in Mstask.h.





LonkeroAdministrator
(KiX Master Guru)
2004-01-17 04:37 PM
Re: Logoff all users

funny is better than irritating.
I still don't see the remote limitations layed out anywhere.
so, seems that I must try it myself if I wanna know... or take your words for it


Co
(MM club member)
2004-01-17 06:57 PM
Re: Logoff all users

Yep, you are right.. Funny is better..

When I schedule a task on a remote pc it has nothing to do with the pc I schedule it from isn't it?
When I schedule for example a task on multiple pc's at 17:00 in different timezones this task will start on every pc's at 17:00 in its own timezone... This has to be the same for idletime...

Why aren't you so sure about scheduling a task on a remote pc with for example TaskScheduleControl()?

I'd like to hear your results after testing it..

again your own UDF library which I like -TaskScheduleControl()

I quoted some parts of this UDF..
Quote:


........; Used by tsDefineTask and tsActivateEvent functions - TASK parameter names
$tsTASKPARMS = "ApplicationName", "Parameters", "WorkingDirectory", "Comment", "Creator", "Priority", "MaxRunTime", "Idle", "DontStartIfOnBatteries", "KillIfGoingOnBatteries", "RunOnlyIfLoggedOn", "SystemRequired", "DeleteWhenDone", "Suspend", "StartOnlyIfIdle", "KillOnIdleEnd", "RestartOnIdleResume", "Hidden", "Interactive", "HaltOnError"....
;
;
;


......;======================================================================
;
;FUNCTION tsDefineTask(TaskAry, TaskParms)
;
;ACTION Loads the specified array with the task parameter pairs.
; The parameter pairs consist of a 3-character mnemonic, "=",
; and a value. Mnemonics represent the 20 JT parameter names,
; and are identified in the table below.
;
;SYNTAX tsDefineTask("TaskAry", TaskParm=val,...)
;
;PARAMETERS UsrAry - Name of task array to populate (as string, w/o "$")
; TaskParm - List of mnemonic=Value Parameter pairs, comma-delimited
;
; Mnemonic Parameter Name Data Type
; APP : ApplicationName String - command to run
; PRM : Parameters String - app parameters
; WKD : WorkingDirectory String
; CMT : Comment String
; CTR : Creator String
; PRI : Priority STring: IDLE, NORMAL, HIGH, REALTIME
; MRT : MaxRunTime Integer (ms)
; IDL : Idle Integer # # (wait & deadline min)
; DSB : DontStartIfOnBatteries Boolean
; KGB : KillIfGoingOnBatteries Boolean
; RLO : RunOnlyIfLoggedOn Boolean
; SRQ : SystemRequired Boolean
; DWD : DeleteWhenDone Boolean
; SUS : Suspend Boolean
; SII : StartOnlyIfIdle Boolean
; KIE : KillOnIdleEnd Boolean
; RIR : RestartOnIdleResume Boolean
; HID : Hidden Boolean
; ITV : Interactive Boolean (currently unsupported by JT)
; HOE : HaltOnError Boolean (currently unsupported by JT)
;
;REMARKS This function parses the parameter=value pairs and loads the
; value into the correct array position. Parameter pairs are separated
; by whitespace. Any character is permitted in the value portion, but
; equal signs (=) must be escaped as "==".
;
;RETURNS nothing - sets @ERROR
;
;DEPENDENCIES none
;
;EXAMPLE tsDefineTask("MyTaskArray", 'APP=kix32.exe PRM=$arg==3 WKD=C:\TEMP')
; "MyTaskArray" is the name of the array that will be loaded.......
;
;
;
;
;



..... ; Certain Trigger types do not require the TypeArguments value to be set. The
; "RQ" flag in element 9 is removed automatically for those...
If InStr("ONCE,ONIDLE,ATSTARTUP,ATLOGON", $tsTrigAry[$tsTrigId,8]) <> 0
$tsTrigAry[$tsTrigId,9] = "" ; remove ReQuired flag for these Types
EndIf..........







Btw: Basta = enough! - En daarmee basta! = And there is an end!


olmeca3332003
(Fresh Scripter)
2004-01-20 12:14 AM
Re: Logoff all users

Interesting discussion, I must say that I got more than expected. I ‘will take the time to go over all that was said, however, I am leaning towards Co’s suggestion about the use of Jt.exe. Fellows, Lankero mentioned an admin script, as a newbie to scripting; those anyone care to elaborate on the creation or startup codes?

Sealeopard
(KiX Master)
2004-01-20 12:27 AM
Re: Logoff all users

I'd recommend to use a solution native to your domain model and policies, rather than coming up with a scripting solution. Thus, login hours restrictions and logoff screen savers might be better solutions than using e.g. a script triggered by 'idle-time' parameters.