United Kingdom
Asked — Edited

Closing A Program Using Exec()

Quick question. As the title suggests, after opening a program or file in Windows 8 using the EXEC() command (e.g, opening a picture), how can you close that program or file using the execute command?

Thanks.


ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

United Kingdom
#9  

Lol, still not doing what it should.

What is the "PhotosApp" for? Is it for the "Windows Photo viewer" app or the "Photos" app? Either way, even with the script you just supplied David, it opens the photo, but doesn't close it (although I do see the CMD window flash up very quickly after the 2 second sleep).

#10  

hmm, interesting. The DLLHost exe is what was keeping it open for me. Try this...

Open the photo.

From a command line try this taskkill /F /IM PhotosApp.exe

Tell me what the next line says.

Then, try this taskkill /F /IM dllhost.exe

Tell me what the next line says.

I am looking to see if a line like this shows up "SUCCESS: The process "PhotosApp.exe" with PID 8312 has been terminated." and then "SUCCESS: The process "dllhost.exe" with PID 7568 has been terminated."

United Kingdom
#11  

Having the photos open with Windows PhotonViewer as default, opening a photo and using the PID code for "dllhost.exe" closes the photo showing...

"SUCCSESS: Sent termination signal to the process with PID 6464.

so all good there.

But within ARC, it's a different matter. Running the script opens the photo, sleeps for 2 seconds, then I see the CMD window flash once, but photo remains open with the script console saying "Done".


exec("C:\Users\steve_000\Pictures\EZ robot project showcase\k9 1.png")

sleep(2000)

$attributes = "/F /IM dllhost.exe>nul"
exec("taskkill",$attributes)
#12  

This works for me from ARC script.


exec("C:\current build progress.jpg")
sleep(2000)
$attributes = "/F /IM dllhost.exe"
Exec( "taskkill", $attributes )

United Kingdom
#13  

Thanks buddy. I'll keep trying things out my end.

#14  

it may be the >nul that was causing the issue. Try to remove that.

United Kingdom
#15  

Yep, you nailed it my friend. Your last script worked for me too.

That's 2 for 2 David. Once again, thanks very much for your help. Most grateful.:)

#16  

Glad we found a solution and happy to help. Thanks Steve.