Can't killprogram()

Just starting out? Need help? Post your questions and find answers here.
rotacak
User
User
Posts: 77
Joined: Tue Feb 14, 2006 2:00 pm

Can't killprogram()

Post by rotacak »

Hi, I have simple code:

Code: Select all

a =  RunProgram("cmd.exe", "", "")
Delay(1000)
Debug a
Debug IsProgram(a)
Debug ProgramRunning(a)
Debug KillProgram(a)
But it will fail at ProgramRunning(a). Can someone explain me why?

Image
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Can't killprogram()

Post by Little John »

Use this:
a = RunProgram("cmd.exe", "", "", #PB_Program_Open)

For details, see the documentation of RunProgram().
rotacak
User
User
Posts: 77
Joined: Tue Feb 14, 2006 2:00 pm

Re: Can't killprogram()

Post by rotacak »

Little John: Thank you. I did not realized that kill program is also "communication" which will need #PB_Program_Open.
BarryG
Addict
Addict
Posts: 3331
Joined: Thu Apr 18, 2019 8:17 am

Re: Can't killprogram()

Post by BarryG »

rotacak wrote:But it will fail at ProgramRunning(a). Can someone explain me why?
Little John gave you the answer (it's in the manual too), but the line before it was your clue: IsProgram(a) returned 0, so you're trying to kill a program that isn't identified.

Code: Select all

a =  RunProgram("cmd.exe", "", "")
Delay(1000)
If IsProgram(a) = 0
  Debug "Program not found"
Else
  KillProgram(a)
  Debug "Program found and killed"
EndIf
Post Reply