DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Send an email when remote computer is not in use  (Read 13,711 times)

screenshots

  • Participant
  • Joined in 2013
  • *
  • Posts: 5
Send an email when remote computer is not in use
« on: April 23, 2014, 07:04 PM »
I do remote IT work for various clients. I always have to call ahead to be sure I am not interrupting anyone's work before logging into their PC. I would find it really useful to be able to have a small program running on the remote computer, that would email me when the client has been away from their computer for a certain amount of time. My particular client has an irregular schedule and I have to jump in and do remote work whenever I get the chance. I can't be calling him up all day to find out if he's using his computer, hence my desire for an email notification.

x16wda

  • what am I doing in this handbasket?
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
    • Participated in NANY Challenge Once
Re: Send an email when remote computer is not in use
« Reply #1 on: April 24, 2014, 01:09 AM »
This utility would do it, although it's pretty primitive. You'd also need to put a copy of blat.exe on the box and set up a batch file to send the email.  If you don't want it to show as a running program, you'd need srvany (or, better, nssm, the non-sucky service manager) to run it as a service.

vi vi vi - editor of the beast

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: Send an email when remote computer is not in use
« Reply #2 on: April 24, 2014, 01:20 AM »
You might also consider an alternative to sending an email -- perhaps a tool that simply updated a web page somewhere with some metrics.  That would be less troublesome than sending emails in my opinion.

x16wda

  • what am I doing in this handbasket?
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
    • Participated in NANY Challenge Once
Re: Send an email when remote computer is not in use
« Reply #3 on: April 24, 2014, 10:26 AM »
True, although the real issue is how do you detect idle time. Can't go by CPU alone, other stuff can get kicked off in "idle time" that uses cpu. Screen saver might be disabled. Probably mouse & keyboard input would be best to check.

On the other hand, you would really also want to be notified when the idle time ends, or you're liable to connect up when the person is back from his snack break.
vi vi vi - editor of the beast

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,652
    • Cody Award
    • Participated in NANY Challenge Five Times
Re: Send an email when remote computer is not in use
« Reply #4 on: April 24, 2014, 12:04 PM »
You might also consider an alternative to sending an email -- perhaps a tool that simply updated a web page somewhere with some metrics.  That would be less troublesome than sending emails in my opinion.

That was my first thought when reading this as well.

On the other hand, you would really also want to be notified when the idle time ends, or you're liable to connect up when the person is back from his snack break.

Bingo! This is really trying to solve a people problem with technology me thinks.

One thing that would help is if we knew what technology is being used for the connection RPD, or VNC. With VNC you can see the user's movements and the user can see their wallpaper change/disappear (assuming they're paying attention). RDP is an all or none which will pull the session away from the user...but they have the option of just taking it back as well.

Mitigating options are first and foremost explaining the situation to the user so they know what to look for when support logs in ... and how to signal them that now's a bad time. If the user agrees to log off when not using/needing the machine, and you use a separate support acct to log in with RDP then the system will flag you that someone else is currently logged in eliminating the guess work. I share access to a machine with several other vendors at a client using this method.

If you are using RDP and the users accounts to access the machines, then just have them take the session back and text/email you at that point with give me 20min or an hour to do X. This has worked well for me while managing several hundred machines for quite a few years now. And annoying as it may seem...people seem to appreciate the human touch afforded by a direct interaction to the hit or miss nature of assumptions required by automation.

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,046
Re: Send an email when remote computer is not in use
« Reply #5 on: April 25, 2014, 11:07 AM »
why not use the chat feature to ask them if now is ok that is built into VNC after you have remoted in? 

BigVent

  • Member
  • Joined in 2013
  • **
  • Posts: 36
    • Participated in NANY Challenge Once
Re: Send an email when remote computer is not in use
« Reply #6 on: May 08, 2014, 08:17 PM »
Here's a very quick example of what you needed.

Notes:
  • Timer is set to fire after 45 minutes of idle time (adjust as needed)
  • Should the program then exit after it fires? (I'm not sure how often you needed notices so I'll leave that up to you)
  • Easy email send via COM - adjust your email & credentials


Enjoy!

Code: (autohotkey)
#SingleInstance, force
#Persistent

time := 2700000	;//45 minutes

SetTimer, check, 300000	;//check once every 5 min
return

check:
	if(A_TimeIdle >= time)
	{
		email()
		SetTimer, check, off
	}
return

;//function email
email()
{
	pmsg 			:= ComObjCreate("CDO.Message")
	pmsg.From 		:= "email@gmail.com"
	pmsg.To 		:= "email@gmail.com"
	pmsg.BCC 		:= ""   ; Blind Carbon Copy, Invisable for all, same syntax as CC
	pmsg.CC 		:= ""
	pmsg.Subject 	:= "PC in question is idle"

	;You can use either Text or HTML body like
	pmsg.TextBody 	:= A_Username " 's PC is idle."
	;OR
	;pmsg.HtmlBody := "<html><head><title>Hello</title></head><body><h2>Hello</h2><p>Testing!</p></body></html>"

	;var := A_ScriptDir
	;msgbox % var
	;"%SPVvar%"|"%VPNvar%"
	;SPVvar := A_ScriptDir "\blah.txt"
	;VPNvar := A_ScriptDir "\blah1.txt"

	sAttach   		= ;%SPVvar%|%VPNvar%


		; can add multiple attachments, the delimiter is |

	fields := Object()
	fields.smtpserver   := "smtp.gmail.com" ; specify your SMTP server
	fields.smtpserverport     := 465 ; 25
	fields.smtpusessl      := True ; False
	fields.sendusing     := 2   ; cdoSendUsingPort
	fields.smtpauthenticate     := 1   ; cdoBasic
	fields.sendusername := "email@gmail.com"
	fields.sendpassword := "password12345"
	fields.smtpconnectiontimeout := 60
	schema := "http://schemas.microsoft.com/cdo/configuration/"

	pfld :=   pmsg.Configuration.Fields

	For field,value in fields
		pfld.Item(schema . field) := value
	pfld.Update()

	Loop, Parse, sAttach, |, %A_Space%%A_Tab%
	  pmsg.AddAttachment(A_LoopField)
	  
	pmsg.Send()
	return
}

esc::
	critical
	exitapp
return
~BigVent

Original address: https://www.donationcoder.com/forum/index.php?topic=37795.0