1. Windows execute but don't wait.

I am a dinosaur in that I am using Eu3, but that shouldn't affect my question.
I have a program which recognises from my website that a new version is available.
It downloads the new setup program, but at that point I get unstuck.
I can't run it because the host program sits and waits for the setup to complete but it can't do so because it's trying to update the very program which is sunning it. Did you follow that?
In DOS I could call exec() and not wait; problem solved. In Win7 I don't seem able to do that. I can call shellExecuteEx() but I can't find any way to leave the invoked program running while the host program carries on and terminates.
So, ladies and gentlemen, how can I get around that? I would appreciate the simple reply "Ah, use EP_NOWAIT" or similar - but I suspect it is more complicated than that. I found no help on MSDN...

Thanks, Andy

new topic     » topic index » view message » categorize

2. Re: Windows execute but don't wait.

AndyDrummond said...

I am a dinosaur in that I am using Eu3, but that shouldn't affect my question.
I have a program which recognises from my website that a new version is available.
It downloads the new setup program, but at that point I get unstuck.
I can't run it because the host program sits and waits for the setup to complete but it can't do so because it's trying to update the very program which is sunning it. Did you follow that?
In DOS I could call exec() and not wait; problem solved. In Win7 I don't seem able to do that. I can call shellExecuteEx() but I can't find any way to leave the invoked program running while the host program carries on and terminates.
So, ladies and gentlemen, how can I get around that? I would appreciate the simple reply "Ah, use EP_NOWAIT" or similar - but I suspect it is more complicated than that.

Thanks, Andy

Can't you use "cmd /c start ..." or Cygwin's run command? http://stackoverflow.com/questions/673278/cygwin-run-script-silenty-from-run-command

new topic     » goto parent     » topic index » view message » categorize

3. Re: Windows execute but don't wait.

AndyDrummond said...

I am a dinosaur in that I am using Eu3, but that shouldn't affect my question.
I have a program which recognises from my website that a new version is available.
It downloads the new setup program, but at that point I get unstuck.
I can't run it because the host program sits and waits for the setup to complete but it can't do so because it's trying to update the very program which is sunning it. Did you follow that?
In DOS I could call exec() and not wait; problem solved. In Win7 I don't seem able to do that. I can call shellExecuteEx() but I can't find any way to leave the invoked program running while the host program carries on and terminates.
So, ladies and gentlemen, how can I get around that? I would appreciate the simple reply "Ah, use EP_NOWAIT" or similar - but I suspect it is more complicated than that. I found no help on MSDN...

Thanks, Andy

Hmm, I think SEE_MASK_NOASYNC is the flag to use with shellExecuteEx().

http://msdn.microsoft.com/en-us/library/windows/desktop/bb759784(v=vs.85).aspx

MSDN said...

The SEE_MASK_NOASYNC flag must be specified if the thread calling ShellExecuteEx does not have a message loop or if the thread or process will terminate soon after ShellExecuteEx returns.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Windows execute but don't wait.

jimcbrown said...

Can't you use "cmd /c start ..." or Cygwin's run command? http://stackoverflow.com/questions/673278/cygwin-run-script-silenty-from-run-command

You might be right ... I thought that cmd would hang but of course if I use "start..." then cmd will return. That is simple enough but I never like using the command interpreter as a tool from a host program. No real reason not to ...

Thanks, Jim

new topic     » goto parent     » topic index » view message » categorize

5. Re: Windows execute but don't wait.

jimcbrown said...

Hmm, I think SEE_MASK_NOASYNC is the flag to use with shellExecuteEx().

http://msdn.microsoft.com/en-us/library/windows/desktop/bb759784(v=vs.85).aspx

MSDN said...

The SEE_MASK_NOASYNC flag must be specified if the thread calling ShellExecuteEx does not have a message loop or if the thread or process will terminate soon after ShellExecuteEx returns.

And hmm yes, I see you are right. I never found that. Too long spent programming other systems than Windies. Again, Jim, thanks. That's MUCH nicer IMHO.

Andy

new topic     » goto parent     » topic index » view message » categorize

6. Re: Windows execute but don't wait.

AndyDrummond said...
jimcbrown said...

Hmm, I think SEE_MASK_NOASYNC is the flag to use with shellExecuteEx().

http://msdn.microsoft.com/en-us/library/windows/desktop/bb759784(v=vs.85).aspx

MSDN said...

The SEE_MASK_NOASYNC flag must be specified if the thread calling ShellExecuteEx does not have a message loop or if the thread or process will terminate soon after ShellExecuteEx returns.

And hmm yes, I see you are right. I never found that. Too long spent programming other systems than Windies. Again, Jim, thanks. That's MUCH nicer IMHO.

Andy

Help! I am struggling with using shellExecuteEx(). The win32lib "shellExecuteEx()" is just an alternative entry to shellExecuteEx(), and doesn't allow me to put in a mask code. I tried - well, all sorts of things, and I'm getting nowhere.

So, Jim, or anyone, do you have an example of how I can invoke shellExecuteEx with a mask code? It should be simple enough - but I'm making heavy weather of it all. Euphoria 3, remember..

Thanks for your help, in advance. I live and learn, just rather slowly it seems to me.

Andy

new topic     » goto parent     » topic index » view message » categorize

7. Re: Windows execute but don't wait.

jimcbrown said...

Hmm, I think SEE_MASK_NOASYNC is the flag to use with shellExecuteEx().

http://msdn.microsoft.com/en-us/library/windows/desktop/bb759784(v=vs.85).aspx

MSDN said...

The SEE_MASK_NOASYNC flag must be specified if the thread calling ShellExecuteEx does not have a message loop or if the thread or process will terminate soon after ShellExecuteEx returns.

AndyDrummond said...

Help! I am struggling with using shellExecuteEx(). The win32lib "shellExecuteEx()" is just an alternative entry to shellExecuteEx(), and doesn't allow me to put in a mask code. I tried - well, all sorts of things, and I'm getting nowhere.

So, Jim, or anyone, do you have an example of how I can invoke shellExecuteEx with a mask code? It should be simple enough - but I'm making heavy weather of it all. Euphoria 3, remember..

Thanks for your help, in advance. I live and learn, just rather slowly it seems to me.

Andy

Looking at http://msdn.microsoft.com/en-us/library/windows/desktop/bb762154(v=vs.85).aspx it seems it's easy to wrap shellExecuteEx() directly.

atom dll_ = open_dll("shell32.dll") 
constant shellExecuteEx_ = define_c_func(dll_, "ShellExecuteEx", {C_POINTER}, C_INT) 
 
public function shellExecuteEx(atom pointer) 
	return c_func(shellExecuteEx_, {pointer}) 
end function 

The hard part is going to be creating the SHELLEXECUTEINFO structure. Based on the previous MSDN page, it looks like it is 15 DWORDS long, or 60 bytes. (This is assuming you are running on 32 bits, the sizes may be different on 64 bit OSes). The mask is the second DWORD, or bytes 4-7 of the structure.

new topic     » goto parent     » topic index » view message » categorize

8. Re: Windows execute but don't wait.

Hi

How I do this.

When an eu program runs, it puts its whole self in memory (does it not?), and does not require the program to acyually be on the disk.

My program checks at regular points for the size of itself. When it first loads up, it records the size of itself in a global variable.

If the size of the program changes is a new version has been uploaded, then a flag is raised and the user is informed that the program needs to be restarted.

It would be a small leap to run an external script to kill all instances of itself, and then restart the updated program (a suicide-phoenix)

Chris

new topic     » goto parent     » topic index » view message » categorize

9. Re: Windows execute but don't wait.

ChrisB said...

Hi

How I do this.

When an eu program runs, it puts its whole self in memory (does it not?), and does not require the program to acyually be on the disk.

My program checks at regular points for the size of itself. When it first loads up, it records the size of itself in a global variable.

If the size of the program changes is a new version has been uploaded, then a flag is raised and the user is informed that the program needs to be restarted.

It would be a small leap to run an external script to kill all instances of itself, and then restart the updated program (a suicide-phoenix)

Chris

I managed to execute the shellExecuteEx OK, but it was the loading and passing of the structure which foxed me. However, Chris, you have a good point; if the startup program is a simple bit of code, it can look to see if there is a setup program present and run that, or, if not, run the main program. I somehow just thought it would be easy to run the setup without wait and then quit. But while most things are easier in Windows compared to DOS, some are dead easy in DOS. Maybe just that I did lots of DOS coding when I was young and adventurous!

So unless there is a simple way for my program to start the setup and then quit, I will do the Chris route with a minimal startup program. Which actually has its merits too. Hmmm. I need to look into this. Then the startup script can update the main program but the main program can update the startup code. Definitely has something going for it.

I'm blaming my inability to think on the heat in the UK; we just aren't used to it.

Thanks again for your help, gentlemen.

Andy

new topic     » goto parent     » topic index » view message » categorize

10. Re: Windows execute but don't wait.

Now I am completely confused. I wrote a simple Eu program to execute the setup using the simple shellExecute() procedure from Win32Lib - and the program started the setup running and then terminated itself. It didn't wait for setup to run to completion before continuing to the abort(0) command. So .. I did the same in my main program: if it finds a new setup is available then:

shellExecute("open", "C:...setup.exe", SW_SHOWNORMAL) 
abort(0) 

And it does exactly what I wanted, with nothing clever or hard. I still feel sure that it CAN'T be right but it seems to be doing just what I want. I've tried it a few times to make sure and yes, it is doing just that.

My understanding of Windows API is clearly terrible; that's why I use Euphoria in the first place! All the work is done by
The "A" Team!!

Andy

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu