Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Create a scheduled task that would log off users at a certain time daily

Posted on 2016-11-03
8
Medium Priority
?
180 Views
Last Modified: 2016-11-07
We tried creating a task but it only works if the user is logged into the machine and the screen is not Locked with the screen saver policy.

Is there anyway to force the log off ?

Users are running windows 7 64 bit
0
Comment
Question by:AGenMIS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 29

Expert Comment

by:Michael Pfister
ID: 41872223
Try
shutdown /l /f 

Open in new window

0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 41872292
It's possible to set a user's logon hours, and then enforce those hours (including forcing logging off) via GPO.
0
 
LVL 56

Expert Comment

by:McKnife
ID: 41873584
@paulmacd: no, force logoff does not logoff the user. It only disconnects from the resource forcefully - this is often mistaken.

@AGenMis: What we do is, create a scheduled task running as system account. It uses a batch that goes:
del %temp%\DisconSessions.txt
del %temp%\delSessions.txt
qwinsta |findstr Disc >%temp%\DisconSessions.txt
findstr /v services %temp%\DisconSessions.txt>%temp%\delSessions.txt
for /f "tokens=2" %%a in (%temp%\delSessions.txt) do logoff %%a

Open in new window

0
How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

 

Author Comment

by:AGenMIS
ID: 41873979
I created a gpo with the scheduled task as shutdown.exe -l -f and just kept the user as %logonuser% and I see the machine getting the policy but the task is not created.

If I run the task on the local machine it runs and logs off the user even if the screen is locked.

Any ideas here maybe the user needs to be an admin?
0
 
LVL 56

Accepted Solution

by:
McKnife earned 2000 total points
ID: 41874013
If you would like to create a task using %logonuser%, that would mean it is a policy targeted to user objects, if I am not mistaken. Did you link the policy to an OU with computer accounts instead?

By the way: we use my suggestion ourselves.
0
 

Author Comment

by:AGenMIS
ID: 41874184
Its a computer side policy linked to a set of computers but the task uses the logged on user account
Capture.PNG
Capture2.PNG
0
 
LVL 56

Expert Comment

by:McKnife
ID: 41874188
I told you, this will not work, as far as I remember (and menanwhile, I tried it - no, it does not). That's due to %logonuser%. We can only use %logonuser% on tasks deployed through user policies. Use my suggestion.
0
 

Author Closing Comment

by:AGenMIS
ID: 41877751
Thanks for your assistance the user side policy did the trick for us
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

OfficeMate Freezes on login or does not load after login credentials are input.
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question