forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


exe already running

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
tgross
Newbie


Joined: 03 Apr 2007
Posts: 4

PostPosted: Thu May 10, 2007 7:33 pm    Post subject: exe already running Reply with quote

Does anybody know how to detect if a vds .exe is already running? I tried using the following code:
LIST CREATE,1
LIST TASKLIST,1
IF @MATCH(1,Utility.exe)
STOP
END
but realized, duh, that since the script was running it would show up in the list. I can't find a way to detect a duplicate item in the list.

I'm kind of a newbie so please be kind No clue
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Thu May 10, 2007 8:33 pm    Post subject: Reply with quote

I think this is the easiest way:
Code:

  REM Check if our window already exists
  if @winexists(#AlreadyRunningWnd)
    REM If it does, show it and then exit
    window activate,@winexists(#AlreadyRunningWnd)
    exit
  end
  REM If it doesn't, then go ahead with our window
  REM Make sure to specify the CLASS of the window. This is what we check above.
  DIALOG CREATE,New Dialog,-1,0,240,160,CLASS AlreadyRunningWnd
  REM If you don't want your exe to have a window, don't show it.
  DIALOG SHOW
:evloop
  wait event
  goto @event()
:Close
  exit

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri May 11, 2007 1:44 pm    Post subject: Reply with quote

Another approach is the way you already told, by looking if an item is in a list multiple times. Although this might work, I think it's best for you to go with SnarlingSheep's example since that will rule out other applications which are using the same exe name. Smile

Code:
list create,1
list add,1,a first
list add,1,b
list add,1,b
list add,1,b
list add,1,b
list add,1,a second
list add,1,b

# Set the list index to zero
list seek,1,0

# Check for the first item
if @match(1,a)
  # With @next(), the list index will be incremented
  info First match found: @next(1)
end

# Check if there is a second match found (or maybe even more?)
if @match(1,a)
  # A second match has been found, you now know for sure an item is in the
  # list multiple times
  info Second match found: @next(1)
end

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
tgross
Newbie


Joined: 03 Apr 2007
Posts: 4

PostPosted: Fri May 11, 2007 7:51 pm    Post subject: Reply with quote

Thanks.

The @WINEXISTS solution worked.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group