Determining if Macro Scheduler currently running

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
jhanasik
Newbie
Posts: 11
Joined: Mon Jan 27, 2003 5:56 pm

Determining if Macro Scheduler currently running

Post by jhanasik » Mon Jan 27, 2003 6:04 pm

I have an Excel macro that runs Macro Scheduler and am in the process of finalizing the code. One thing that I would like to do is to stop the Excel macro and issue a message to the user if Macro Scheduler is currently running as I do not want to run any of my scripts if it is. Anyone know to do this. I have tried Windows API for findwindow but it fails to work. Thanks in advance.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Jan 27, 2003 11:31 pm

A few thoughts off the top of my head........

:idea: Would a Macro Scheduler Message Modal Box help out?

:idea: Use it in conjunction with Let>MSG_STAYONTOP=1

:idea: You could also use the Macro Scheduler to minimize the Excel window, and :idea: temporarily rename the EXCEL.EXE file until the Macro Scheduler routine is completed.

None of these are foolproof (nothing ever is!), just trying to set up a quick nuisance barrier.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Jan 28, 2003 1:13 am

Hi jhanasik,

Would you kindly clarify whether or not you want to terminate Macro Scheduler when and if any Excel macro starts running?

Happy scripting!

Guest

Post by Guest » Tue Jan 28, 2003 3:22 am

To armsys,

No I really don't want to terminate Macro Scheduler if the Excel macro detects that a Macro Scheduler script is running. I just want to detect it's existence and notify the user to shut it down. This will make the user investigate why a script is still running. Perhaps a previous execution of a script missed it's timing has stalled. I may not be able to successfully detect the running script and will just have to educate the user to make sure they don't see Macro Scheduler showing in the taskbar but you know how users can be---they will forget and kick the Excel automation off and it will get all mucked up if a previous one did not complete to a normal end.

To bob hansen,

I guess I'm dumb. I can't see how your response will help excel detect that a Macro Scheduler script is running. Can you explain further?

Thanks to you both for your responses

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Jan 28, 2003 3:37 am

Hi Guest,

Thanks for posting your Macor Scheduler issue here.

First, you run tasklist.exe to produce a text file listing the names of all currently running processes.

/*--- Run TaskList.exe ---*/
run>c:\windows\command\tasklist.exe >c:\temp\Process.txt

The location of your TaskList.exe may vary.

If Macro Scheduler is currently running, you can see "Msched.exe" is somewhere on the list. Instead of manual visual scanning, of course, you can automate the detection by Macro Scheduler by reading the text file line by line.

Keep posting your technical issues here. Thanks.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Jan 28, 2003 3:58 am

I was thinking that you wanted a user to know if Macro Scheduler was running. I was not addressing it from the point of Excel knowing it was running.

If Excel calls up a Macro Scheduler macro, have the MS macro use ResizeWindow> to put up a LARGE MessageModal> Box that will not go away.

In my earlier message I mentioned using MessageModal> but that was an error. I meant to suggest using
Let>MSG_STAYONTOP=1
Let>MSG_CENTERED=1

Perhaps the message could say "Press SHIFT-ESC to stop Macro Scheduler macro". This message box would remain on top of Excel program and would only go away when MS macro replaced it at end of macro routine.

If macro needs other messages, perhaps put the SHIFT-ESC message at the top of these other messages using %CRLF% as needed.

Instead of CENTERED, you could put in a loop to keep moving the MessageBox's position to provide additional visual attention.

You could also use PlayWav> to have an audible notification along with the MessageBox. (You would have to make a loop to repeat its playing).

Make the movement of the window and/or the sound file a sub-routine.

Again, these thought were to notify a real user that a MS macro was running.

"The trouble with making something 'idiot-proof' is that the idiots are so smart". ---(Source unknown). They keep finding new ways to do something.

Hope this clarifies my thoughts.......good luck....
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Lumumba

Post by Lumumba » Tue Jan 28, 2003 11:42 pm

Hi,
how about this:

Script A

Code: Select all

EditIniFile>C:\Status.ini,MSched,Active,YES
.
.
.
Label>Done
EditIniFile>C:\Status.ini,MSched,Active,NO

Script B

Code: Select all

ReadIniFile>C:\Status.ini,MSched,Active,status
IF>status=YES, End
.
.
.
As long as script A hasn't finished correctly script B won't start.
You can work as well with notify files: WLN> --> DeleteFile> --> IfFileExists>

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Jan 29, 2003 12:19 am

Thanks Lumumba

I like that simple ini file solution.

I don't think it is going to solve the problem that "guest" is concerned about, but it gives me some ideas as solutions for some other situations.

Thanks for tickling the noodles.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sun Feb 02, 2003 1:31 pm

Don't forget you can go to Tools/Options and deselect 'Allow Multiple Instances'. Then Excel cannot run Macro Scheduler if it is already running.
MJT Net Support
[email protected]

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