Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ALLOWING ONLY ONE PROCOMM SESSION AT A TIME

Status
Not open for further replies.

wingdingking

Programmer
Jul 22, 2005
1
US
We have several scripts that run at different times using the scheduler. Sometimes one script doesn't finish before a second one begins. This is causing problems with data getting corrupted.
Is there a way to allow only one PW5.EXE to execute at a time? Or put another way, to not run a script if Procomm is already running.
I found a sample script at aspectscripting.com that contains some logic that determines if a Outlook is open and running an thought I could modify it (see below)
I think I can adapt this script to look for PW5.EXE running or not, but don't know enough about scripting in Procomm to write the code to stop the second script.
I thought I would test for a running Procomm and then set a variable. Then if the variable is "1" stop the current script. I don't know how to end a script using aspect other than putting it within if/end loop. Can you jump to the ENDPROC command once the variable is set?

Your help in formatting a script would be greatly appreciated.

--------

Script that searches the Windows task list to find Outlook, brings it to the foreground, opens a new message, and places the focus in the Subject line:

proc main
integer iTask, iWindow, iStatus = 0
string sTaskName

if firsttask iTask ;Search list of tasks for outlook.exe
taskname iTask sTaskName
if strnicmp sTaskName "outlook.exe" 11 ;Search for Outlook process
taskwin iTask iWindow
winactivate iWindow ;Bring Outlook to foreground
launch_message() ;Run procedure to open new message
iStatus = 1 ;Set flag indicating Outlook was found
endif
while nexttask iTask
taskname iTask sTaskName
if strnicmp sTaskName "outlook.exe" 11
taskwin iTask iWindow
winactivate iWindow
launch_message()
iStatus = 1
endif
endwhile
endif
if iStatus == 0 ;Outlook not active
run "c:\program files\microsoft office\office\outlook.exe"
pause 5
launch_message()
endif
endproc

proc launch_message
pause 3
sendkey CTRLSHIFT 'M' ;Open new message
pause 1
sendkey ALT 'J' ;Move to subject line
endproc
 
Probably the best way to do this would be to use the firsttask and nexttask commands to iterate through the list of tasks on the machine (see the firsttask discussion in the help file for a script that shows how to do this). If the script that just started found more than one instance of PW5.EXE in the list, then it would need to close by using the exit command.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top