Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global logoff of users at specific time

Status
Not open for further replies.

andymac3000

IS-IT--Management
Nov 2, 2004
44
0
0
GB
Is there a way to log off all users citrix sessions at a specific time ? I know you can logoff users after a period of time, but I need to be able to logoff all users at 6pm.

I know a reboot would do this, but is there a nicer way ?

Thanks

Andy
 
Can't you set a policy in the Users and Computers not allowing them to log in at a specific hour. That will gracefully ask them to log out, then log them out. Giving you an hour window to do your housekeeping!

Carl.
 
Ogi, I presume your meaning the logon hours in the account tab of the user properties in users and computers ?

If so, i tried this, and while it prevented me logging on at a certain time as expected, when i logged on before the time limit, and then left it logged on after the time limit, it didnt ask me to log off and just stayed connected.

Ive searched gpo's and cannot find a setting also, so I am still searching if anyone has any ideas ?

Andy
 
If you are still interested I wrote an NT/2K command file (batch file) that calls a VBScript to do what you need, I have this set up on both my old MF 1.8 boxes and my XP boxes to kick users off at a specific time so I can run nightly processing. the command file loks like this

FOR /F "skip=1 tokens=3,4" %%h IN ('quser') DO IF "%%i"=="disc" RESET SESSION %%h
quser>quser.txt
cscript nghtutilusrs.vbs
FOR /F "tokens=3,4" %%h IN (results.txt) DO LOGOFF %%h

The first two lines are really one but got wrapped when I pasted them in.

The first thing it does is reset any disconnected sessions then does a QUSER to an output file.
This file is used as input to a VBScript that strips out certain user ID and puts the rest of the data into another file (results.txt) which is then read and the users I want logged off are dropped.

Here is the VBS watchout for the wordwrap.

' NGHTUTILUSRS.VBS
' This script creates an output file of users still logged into a Citrix server.
' The output file is used by the FOR command to logoff these users
' The colling command file first runs the FOR command against a memory file created
' by the QUSER command to reset any disconnected sessions.
' FOR /F "skip=1 tokens=3,4" %%h IN ('quser') DO IF "%%i"=="disc" RESET SESSION %%h
' The calling command file then runs the QUSER command to a text file called QUSER.TXT
' which is then used as input for this script.
' QUSER>QUSER.TXT
'
' Define Variables
DIM objFSO
DIM strLoggedOnUsers
DIM compString
DIM compVal
'
' Create a File System Object so we can manuipulate the files.
Set objFSO = CreateObject("Scripting.FileSystemObject")
'
' Open the input file (QUSER.TXT) in read-only mode
Set objInputFile = objFSO.OpenTextFile("quser.txt",1)
'
' Create and open the output file (results.txt) in read-write mode
Set objOutputFile = objFSO.OpenTextFile("results.txt", 2, True)
'
' Skip the first line of the input file
objInputfile.SkipLine
'
' Read the rest of the input file
Do Until objInputFile.AtEndOfStream
'
' Read a line of data from the input file and put in the variable
strLoggedOnUsers = objInputFile.Readline
'
' Extract the 4th through 8th characters from the input data
compString = Mid(strLoggedOnUsers,4,5)
'
' Compare the extracted data to the constant "night"
compVal = StrComp(compString, "night", 1)
'
' If the compared strings do not match write the input data to the output file
if compVal <> 0 then
objOutputFile.WriteLine(strLoggedOnUsers)
end if

' go back to the begining and get the next line of input data
Loop
'
' After reading and processing the input file close both the input and output files
'
objInputFile.Close
objOutputFile.Close

'
' After the output file is created (RESULTS.TXT) it is used by the FOR command to
' gracefully logoff users and close any open files.
' FOR /F "tokens=3,4" %%h IN (results.txt) DO LOGOFF %%i
 
Thanks for the Script Maleyj

One thing I didnt specify actually is that its likely there will be a mixture of active and disconnected sessions, can the first script be modified to reset both?

And also from the way I read the scripts, how come you need to use the second script if the first script actually resets the first session, as the reset would act as a logoff ? (sorry, im no VB wiz !)

If thats the case, can we just use a logoff rather than a reset ?

Thanks

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top