help to write a script to umload a program from system tray

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
perfection
Newbie
Posts: 6
Joined: Sat Sep 02, 2006 6:47 am

help to write a script to umload a program from system tray

Post by perfection » Sat Sep 02, 2006 6:50 am

I wish to unload a particluar program running in the system tray followed by a computer shutdown as this program freees explorer and interferes with the shutdown...is this possioble from a keyborad run command that i may then add the shut down script after a wait??

If so - do help

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

Post by Marcus Tettmar » Sat Sep 02, 2006 8:10 am

The simplest way is just to kill the process. What is the name of the process that has the system tray icon? You may be able to figure it out by looking at the process list in Task Manager. Or you may know it already. Then you can kill the process with this script:
http://www.mjtnet.com/forum/viewtopic.php?t=1779

If the system tray has a hidden window (they often do) you may also just be able to use CloseWindow.

What is the window title of the window that appears when you double click on the system tray icon? Use that with CloseWindow. Or use GetWindowProcess with that title to determine the process that needs killing.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

perfection
Newbie
Posts: 6
Joined: Sat Sep 02, 2006 6:47 am

Post by perfection » Sat Sep 02, 2006 9:31 am

The name of the file i wish to kill (unload) before i power off is wfxload.exe
Can i merge the script to unload and the one to shut-off winXP intro one macro

What is the script to power-off windows?
Last edited by perfection on Mon Sep 04, 2006 4:29 am, edited 1 time in total.

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

Post by Marcus Tettmar » Sat Sep 02, 2006 9:38 am

Yes, the script can do both. Your script would be:

Code: Select all

VBSTART
Sub killProcess(pgm)
  set wmi = getobject("winmgmts:")
  sQuery = "select * from win32_process " & "where name='" & pgm & "'"
  set processes = wmi.execquery(sQuery)
  for each process in processes
    process.terminate
  next
End Sub
VBEND

VBRun>KillProcess,wfxload.exe
ShutDownWindows>0
Actually you may only need this line:

ShutDownWindows>3

This does a forced shutdown which forces any running processes to terminate.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

perfection
Newbie
Posts: 6
Joined: Sat Sep 02, 2006 6:47 am

Post by perfection » Sun Sep 03, 2006 5:35 am

Thank you mtettmar
Just four more things

1) When you say i may require only the last line you mean not all that scriptinbg above it ?? just that ONE line??

2) Is it right that i cannot achive this by recording a macro using mouse clicks and keyboard because the position of the icon of windowfx may not be in the same location in my system tray each time. Is there are series of keystrokes alone that can unload the program (preferably without bringing up the task manager)

3) can i make my macro or create the script usng macro scheduler and then remove the program if i do not need more maros - will it work or is it necessary to have the prgram running

4) How to record a keystroke/mouse macro for shutdown as the pc goes off ultimately and the said keystrokes will not get saved anywhere
Last edited by perfection on Mon Sep 04, 2006 4:32 am, edited 1 time in total.

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

Post by Marcus Tettmar » Sun Sep 03, 2006 8:31 am

Hi,

1) Correct, you may only need this ONE line. Try it.

2) Correct, recording using mouse clicks will not be reliable in this case as the position of system tray icons changes. However, you may be able to use this keyboard approach:
http://www.mjtnet.com/blog/2006/07/13/a ... ray-icons/

3) If you have Macro Scheduler Pro you can compile the script to an EXE and then you do not need the software installed. But without Macro Scheduler Standard you need the software running for the macro to work.

4) Well actually you can record/play mouse/keystrokes for shutdown, but there is absolutely no need. Just make a macro with this one line:

ShutDownWindows>0

For a forced shutdown use:

ShutDownWindows>3

See the help file topic ShutDownWindows.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

perfection
Newbie
Posts: 6
Joined: Sat Sep 02, 2006 6:47 am

Post by perfection » Mon Sep 04, 2006 4:28 am

I assume the the VB script you answered in your first reply is to be stored as a scp file and with macro scheduler installed otr is it independant of macro scheduler?

Likewise the window shut-off script??

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

Post by Marcus Tettmar » Mon Sep 04, 2006 5:59 am

The code I gave you is a Macro Scheduler macro. Just paste the whole lot into a new Macro Scheduler macro.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

perfection
Newbie
Posts: 6
Joined: Sat Sep 02, 2006 6:47 am

Post by perfection » Tue Sep 05, 2006 8:25 pm

Thanks for everythng - worked just great

perfection
Newbie
Posts: 6
Joined: Sat Sep 02, 2006 6:47 am

Post by perfection » Thu Sep 07, 2006 4:28 am

I did write create the script you gave me and it worked except that the icon in the system tray does not dissappear - but the process is killed in task manager (hovering the mouse above th esystem tray icon does make that dissappear as well)

But when i converted the script to an exe it gives an error on execution - any ideas about this?? I did this for several scripts with the same result

By the way can the program memorize and record a series of keystroke and mouse movement combinations to playback and perform an action?

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Thu Sep 07, 2006 2:57 pm

Please post the error you see when you try to run the exe version of the script.

...and do you get this error when you attempt to create the exe or when you attempt to run the exe?

and, yes, macroscheduler can record keyboard and mouse activity for simple playback....You may want to edit the recorded code to improve the reliability of your script.

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