08-13-2019, 07:14 PM | #16 | |
Bibliophagist
Posts: 35,380
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
%~dp0MyProgram.exe -u %1 The %~dp0 variable points to the drive and path of the batch file which is the same location you have the .exe file located. Otherwise, you'll need to either have the path to the executable in one of Window's path variable or specify the full path to the the executable. |
|
08-13-2019, 08:26 PM | #17 |
Grand Sorcerer
Posts: 27,548
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I fear the situation is much more dire. In fact, I'm honestly not certain .bat|.cmd files ever worked with the Open With feature before Windows 10. Something with Windows 10 seems to have changed, but all examples of using QProcess::startDetached() to run batch files on Windows that I've run into seem to suggest that it's "cmd.exe" that needs to be launched. And that the batch file needs to be one of the arguments to cmd.
Something like: Code:
return QProcess::startDetached("cmd.exe", {"/k", "C:\Path\to\mybatchfile.bat"}, "C:\Working\Dir"); |
08-13-2019, 08:50 PM | #18 | |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
|
|
08-13-2019, 09:01 PM | #19 | |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
|
|
08-13-2019, 09:22 PM | #20 | |
null operator (he/him)
Posts: 20,567
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
I doubt more than 20% of Sigil users use the Open With feature. And some people, including me on occasions, just shrug when something doesn't work and find another way. Not saying that's what you should do - just saying I'm not surprised it hasn't been reported until now. BR |
|
08-13-2019, 09:26 PM | #21 |
Grand Sorcerer
Posts: 27,548
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
You're the first person (@RbnJrg) I can recall having ever asked about launching external programs with additional parameters.
Besides ... it wouldn't be the first time a different version of Qt behaved differently than the previous one. We haven't been building Sigil with 5.12.3 for very long in the grand scheme of things. It's entirely possible it may worked with Qt5.6.3 on Windows 7. Who knows. The point is that we allow Windows users to select bat and cmd files for Open With, so it either needs to work (on all supported versions of Windows) or we need to limit Open With to exes. Last edited by DiapDealer; 08-13-2019 at 09:29 PM. |
08-13-2019, 10:02 PM | #22 |
Grand Sorcerer
Posts: 27,548
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
For what it's worth; subverting the Open With feature to launch batch files, that in turn launched python scripts that could modify the files in Sigil's scratch directory was how I created my first Sigil "plugins"--before there was such a thing as a Sigil plugin framework.
And since I was doing that on Windows Vista, I'm fairly certain Open With was perfectly capable of launching batch files on XP/Vista/Windows 7 at some point (especially considering that the way Open With launches external programs hasn't really changed since its inception). So I'm betting this is Qt's fault. I've got an idea to fix it, though. Just need to find a little time. Last edited by DiapDealer; 08-13-2019 at 10:05 PM. |
08-13-2019, 10:57 PM | #23 | |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
I am not sure how this works for Windows:
Code:
if (QFile::exists(filePath) && QFile::exists(application)) { QStringList arguments = QStringList(QDir::toNativeSeparators(filePath)); return QProcess::startDetached(QDir::toNativeSeparators(application), arguments, QFileInfo(filePath).absolutePath()); } Quote:
As I read the Qt docs, this will change to that working directory, before launching the application (full path to the application) with the arguments being the full absolute path to the file to be edited. Not sure what would happen if working directory was given with forward slashes. If wherever that ends up, the user has no executable or write permissions, it would fail I think? Not sure why this works in Windows 10 unless the working directory parameter is massaged somehow. Or am I missing something? Last edited by KevinH; 08-13-2019 at 10:59 PM. |
|
08-13-2019, 11:11 PM | #24 |
Grand Sorcerer
Posts: 27,548
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I don't think you're missing anything. That overloaded function has been used the way it's being used since Open With began. And as I mentioned, I know it has worked with .bat files on other versions of Windows in the past. So I think it's probably just Qt being stupid for some reason with 5.12.3.
I'll see if converting the 3rd parameter to native separators makes any difference. |
08-17-2019, 04:29 PM | #25 |
Grand Sorcerer
Posts: 27,548
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I think I have this fixed now in the master branch. @RbnJrg: PM me if you want a beta-build of Sigil to test-drive.
|
08-17-2019, 06:36 PM | #26 |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Troubleshooting Kindle Dx Graphite with corrupted software, does not switch to "registered" | wincel | Amazon Kindle | 26 | 10-03-2020 11:05 AM |
Alter Double-click behaviour to "edit metadata" instead of "open ebook?" | Feather_Qwill | Library Management | 5 | 09-15-2013 11:20 AM |
How to remove "Fully read" books from "Last Open" list? | pjeanetta | PocketBook | 4 | 12-08-2010 10:30 AM |
"Liquid" / "Fixed" - how to switch layouts | Alexander Turcic | Announcements | 0 | 06-05-2007 09:29 AM |
Sony Connect "Bait and Switch" Advertising? | TheMooch | Sony Reader | 5 | 02-21-2007 01:43 AM |