background script needs to notify logged in user

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
bbrink
Pro Scripter
Posts: 71
Joined: Thu Dec 31, 2009 2:36 am
Location: Minnesota
Contact:

background script needs to notify logged in user

Post by bbrink » Sun Sep 25, 2016 9:47 pm

Hi

I run scripts in the background of the computer and have one that needs to notify the logged in user when it finishes. Just about any type of notification message box or pop up bubble would be fine.

Example:
"We've upgraded your application in the background and you can start using it again."

How can this be accomplished?

Thanks in advance for any help.

Bob

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: background script needs to notify logged in user

Post by Marcus Tettmar » Mon Sep 26, 2016 7:59 am

Code: Select all

MessageModal>We've upgraded your application in the background and you can start using it again.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

bbrink
Pro Scripter
Posts: 71
Joined: Thu Dec 31, 2009 2:36 am
Location: Minnesota
Contact:

Re: background script needs to notify logged in user

Post by bbrink » Mon Sep 26, 2016 4:37 pm

Hi Marcus,

I should have mentioned, by "in the background" I meant I am logged into Windows on their computer as another user. I don't think message modal will work for that will it?

Bob

User avatar
JRL
Automation Wizard
Posts: 3531
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: background script needs to notify logged in user

Post by JRL » Mon Sep 26, 2016 7:15 pm

I don't know your system or if you have Macro Scheduler Pro or multiple copies of Macro Scheduler. The way I'd do this is I would use a script similar to below and I'd compile it. I would set it in motion on the users computer and let it run forever, in fact I would have it in the start folder so it restarts every time the user logs in. The first line is setting variable vFileName to a file that is in a location accessible to both you and the user.

When you finish your process you write whatever message you want the user to see to the file that is defined in variable vFileName. The moment the file exists the text of the file will display in a Macro Scheduler message box on the users desktop. When the user dismisses the message the text file will be deleted.

On your end you might also want to do some checking in case the user does not dismiss the message (which deletes the text file) before you create a second text file.

Code: Select all

Let>vFileName=L:\JRL\MessageFile.txt

OnEvent>File_Exists,vFileName,0,srtMessage

Label>Loop
  Wait>0.01
Goto>Loop

SRT>srtMessage
  ReadFile>vFileName,vData
  MessageModal>vData
  DeleteFile>vFileName
END>srtMessage

bbrink
Pro Scripter
Posts: 71
Joined: Thu Dec 31, 2009 2:36 am
Location: Minnesota
Contact:

Re: background script needs to notify logged in user

Post by bbrink » Tue Sep 27, 2016 12:01 pm

JRL,

Thank you for the thoughtful response. Your method can be adopted for a lot of things is very flexible.

I also found that this works on any machine powershell is installed on. Keep in mind my need was for message to pop on local machine, not another machine. If you need to message another machine see the url in the comments.

Code: Select all

/*
Msg Command Syntax
msg {username | sessionname | sessionid | @filename | *} [/server:servername] [/time:seconds] [/v] [/w] [message]
more here:
http://pcsupport.about.com/od/commandlinereference/p/msg-command.htm
*/

Let>RP_Admin=1
Run>powershell.exe msg * "Upgrade done! You may resume using Upgraded Program on this computer"


User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: background script needs to notify logged in user

Post by CyberCitizen » Tue Sep 27, 2016 12:09 pm

Code: Select all

      Run>%SYS_NATIVE%\cmd.exe /c REG ADD "\\%SSTOOLS.COM%\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v "AllowRemoteRPC" /t REG_DWORD /D 1 /F > "%TEMP_DIR%AllowRemoteRPC.txt"
      //Run>%SYS_NATIVE%\cmd.exe /c MSG /V /TIME:172800 /SERVER:%SSTOOLS.COM% * <"%TEMP_DIR%MSGUtility.txt" >"%TEMP_DIR%MSGResponse.txt"
      Run>%SYS_NATIVE%\cmd.exe /c MSG /V /TIME:172800 /SERVER:%SSTOOLS.COM% * <"%TEMP_DIR%MSGUtility.txt" >"%TEMP_DIR%MSGResponse.txt"
      Run>%SYS_NATIVE%\cmd.exe /c REG ADD "\\%SSTOOLS.COM%\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v "AllowRemoteRPC" /t REG_DWORD /D 0 /F > "%TEMP_DIR%AllowRemoteRPC.txt"
This is what I use to send messages to all logged on users (suggest not actually running in on terminal services) but it works for standard windows machines.
FIREFIGHTER

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts