Jump to content

Stop process if user switches to another account

Recommended Posts


I am trying to write a script for my PC which starts a Monero miner when the user is absent. I have gotten this far and the script is working as intended except for one thing: 

#include <Timers.au3>
While 1
   $idleTimer = _Timer_GetIdleTime()
   If $idleTimer > 3000 And Not ProcessExists("xmr-stak.exe") Then
   ElseIf $idleTimer < 10 Then

The issue is Switch user is often used as it's a family PC and when someone switches to a different account to which the script is running the script detects the user idle and starts the miner.

Is this a limitation with idletimer or can I do something about it?

This is my first time using Autoit or doing programming of any kind so please excuse my noobness.  :ph34r:



Share this post

Link to post
Share on other sites

you will need to be able to detect user switches. I found this. in that post he gets it working. You can use that code if it works for you or adapt it to your needs.


My resources are limited. You must ask the right questions


Share this post

Link to post
Share on other sites

Thanks for the reply but I managed to get it working through Task scheduler. 

I compiled a new script which kills all the necessary processes and set it to trigger on user disconnecting from session in Task Scheduler. 

Seems to work seamlessly. :D

  • Like 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now