Project

General

Profile

Does exiv2 have a -silent flag to not show console window?

Added by Bob Davies over 11 years ago

I'm trying to launch exiv2 in the background from a firefox window, but there is currently a bug in firefox which causes executable called at the commandline (when executed on windows) to display the console (and not very gracefully either).
I'm just wondering if maybe exiv2 has a -silent flag to not show console window?
It's not critical or anything, but I'm hoping to avoid kludging it with vbscript or anything like that.
Cheers
Bob


Replies (8)

RE: Does exiv2 have a -silent flag to not show console window? - Added by Robin Mills over 11 years ago

Bob

This is quite common 'windowsism'. Python provides two variants - python.exe and pythonw.exe. python.exe is the (dos) command line version and will throw a dos box thing on the display if you fire him from most apps (with the system() or some variant). pythonw.exe however starts the python interpreter in a 'windows' environment (and no horrible dos box).

I think it is however possible to start processes with the CreateProcess Win32 call and avoid the horrible dos box thing. And I believe you can access the Win32 APIs from VB (or via a com object or something). I don't know anything about Firefox plugins, however it sounds as though they should be using CreateProcess, however they've dropped you in trouble by using system() - and you've got this dos box thing on the glass. Yuck!

So it's not quite as simple as adding a flag -silent, the medicine is probably to add a new build target exiv2w which links exiv2 using the 'windows' environment. I think I'm willing to do that for you in the MSVC branch. However I'm not willing to offer anything at the moment for the cygwin build. For sure, I will not commit new build targets without Andreas's agreement.

So..... maybe you could say a little more about this. If you can fix this from VB (with CreateProcess or something) then I don't need to do anything. If you need assistance, I think I'm willing to do a private build of exiv2w for 0.19 with MSVC. Are you using (or even better, building) with MSVC build. Or do you use the precompiled Cygwin binaries?

RE: Does exiv2 have a -silent flag to not show console window? - Added by Bob Davies over 11 years ago

Aye, they changed to using ShellExecute instead of CreateProcess in 3.0, so it created this problem on windows (cos mac and linux are fine).
I was just hoping there might, maybe, possibly have been a -s flag hidden in there somewhere ;)
It can be worked around by using vb or simple executable (like hstart) to launch exiv2 quietly, it just means I may have to make end-users aware that some anti-virus or anti-malware may kick up alerts as a result.
I think I'll try knocking together a very simple exe for sending the call using CreateProcess, then compiling that for 'windows' env.
Thanks :)
Bob

RE: Does exiv2 have a -silent flag to not show console window? - Added by Robin Mills over 11 years ago

That's interesting, Bob. I started thinking about this at breakfast this morning and thought "linking it to run as a windows app isn't the solution because you probably want to use the stdout stream".

The solution is to provide a helper app which runs our "everyday" exiv2 application which writes to stdout on an invisible desktop. Servers like IIS run on an invisible desktop. The horrible dos box is still there of course, however nobody ever sets the invisible desktop to be their active desktop (although I have in the past).

Incidentally, it's impossible for us to fix this from the command-line version of the console application exiv2.exe. The dos box is created to host exiv2.exe. So the box is on the display before we've arrived at main().

And then you mentioned hstart. Sounds like Hidden start to me. I googled it and you're 100% on the money: http://www.ntwind.com/software/utilities/hstart.html

I think hstart does exactly the following: It launches a target (exiv2.exe) on the invisible desktop with CreateProcess. You've solved it without us having to change anything. Thanks.

RE: Does exiv2 have a -silent flag to not show console window? - Added by Bob Davies over 11 years ago

Yes Hidden Start is something I've used a few times in the past for running apps locally or for friends, but really couldn't face a slew of "[insert virus scanner name here] says your app is a virus, you suck!" so rather than use the well known (and rather heavyhanded) hstart, thanks to your console app as a windows app suggest, I've put together a pretty basic C++ app which can be used to proxy the call.
It's a simple wrapper for a CreateProcess call with the showWindow flag set off, and since I'm mainly using -eX or -iX the stdout isn't a requirement for me.

It took a bit of digging a little deeper into the compiler options than I usually do, but looks like it will do the trick. Almost finished, just struggling to remember my C pointer/array references and conversion stuff (was in c# for way too long and got very lazy), but will post a link here when it's done for anyone else facing the same problem :)

Thank you very much for the help :)
Bob

RE: Does exiv2 have a -silent flag to not show console window? - Added by Robin Mills over 11 years ago

Bob

I'll be very happy to review your code if you wish. I am a C++ warrior - so I'm used to the pain of pointers and stuff.

RE: Does exiv2 have a -silent flag to not show console window? - Added by Bob Davies over 11 years ago

I've put together a very simple wrapper to CreateProcess which can be used to call executables silently.
You can get it here: http://www.robertadavies.co.uk/2010/04/silentstart/
My knowledge of C/C++ is very limited, so I'd appreciate some eyes on the code (included in the download) and any feedback or improvements are appreciated.

RE: Does exiv2 have a -silent flag to not show console window? - Added by Robin Mills over 11 years ago

Bob

I looked at the code, built and and ran it without any trouble on Dev Studio 2008 Std Edition. DevStudio C++ Express 2008 complained about afxres.h not being available to the resource compiler. afxres.h is a Microsoft file and I don't think it's redistributable. So.... Express can't deal with it.

I looked at the code and it looks OK to me. I'm rather surprised it's so simple. I think it'd be a little more complex if you wanted to capture stdout somewhere (but not very much more complex). Good Job!

If this achieves your aims, then I see no reason for you to spend more time at the moment. I think you should maybe consider supporting unicode as your plugin could be used in locales where this is mission critical - such as south east asia. I'm sure you wouldn't want Andreas' wife to report a bug to you now, would you? (mind you I'm sure Andreas does let his mrs use windows!).

RE: Does exiv2 have a -silent flag to not show console window? - Added by Bob Davies over 11 years ago

Thanks :)
Aye, I tried to output messages to the console, but couldn't figure it out. Presumably the stdout handle isn't available for some reason. No idea why.
It's built as unicode, but again, encodings aren't something I'm familiar with (another C# handhold preventing actual learning) I've ended up using the A commands (presumably ansi, rather than wide) as that's what seems to work, but beyond that I don't really understand 'why' it works to use those instead of the W ones lol :D

    (1-8/8)