3

How can I make file association in Qt installer framework(1.5.0) on Windows? I want to do this:

For example, when I double click myFile.x then my qt desktop application(Windows) will launch and open this file.

I want to correct this in installscript.qs :

component.addOperation("CreateShortcut", "@TargetDir@/A.exe", "@StartMenuDir@/A.lnk");
component.addOperation("RegisterFileType", 
                       "fl", 
                       "@TargetDir@\\A.exe" + "'%1'", 
                       "myFiles", 
                       "text/plain",
                       "@TargetDir@/A_icon.ico", 
                       "ProgId=A.fl");
component.addOperation("CreateShortcut", "@TargetDir@/uninstall.exe", "@StartMenuDir@/Uninstall.lnk");

When I write this string, it gives parse error. Output is : Caught exception: Exception while loading component script: 'D:/Workspace/A/A_installer/A/packages/com.ge.mss/meta/installscript.qs

SyntaxError: Parse error

Backtrace: ()@D:/Workspace/A/A_installer/A/packages/com.ge.mss/meta/installscript.qs:102'

MBach
  • 1,647
  • 16
  • 30
Wilmort
  • 294
  • 2
  • 15
  • So you have otherwise working installer, but just don't know how to do this? Showing relevant (possibly anonymized) configuration files/data you have now would make the question easier to answer, by telling you what you need to add. – hyde Sep 01 '15 at 05:29
  • Actually, I want to correct this script in installscript.qs : component.addOperation("RegisterFileType", "fl", "@TargetDir@\\A.exe" + "'%1'", "myFiles", "text/plain","@TargetDir@/A_icon.ico", "ProgId=A.fl");​ When I write this string, it gives parse error. – Wilmort Sep 01 '15 at 07:17
  • 1
    Next time, you should edit the question to add information like that, and also format it nicely. But check my edit and fix, if I made some mistake there. – hyde Sep 01 '15 at 07:39
  • 1
    Also, could you add the console output showing the parse error, and also previous lines in installscript.qs, because that one line looks like syntactically valid. Parse and syntax errors in a line are often caused by a previous line having a mistake. – hyde Sep 01 '15 at 07:42
  • I put previous line but this is working script, I added only this line after that. Problem is about this line that can shown from output. – Wilmort Sep 01 '15 at 12:11

1 Answers1

3

If you are using windows just follow this:

component.addOperation("RegisterFileType",
                       "bob",
                       "@TargetDir@\\BobiSoft.exe \" %1\"",
                       "BobiSoft Files",
                       "application/x-binary",
                       "@TargetDir@/bobi_file_icon.ico",
                       "ProgId=BobiSoft.bob"); 

I also had this problem, the trick was to replace the ' %1' as many examples say, with \" %1\".

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • Hi, please take a look at [my script file](https://www.dropbox.com/s/hq6e2340ehulhqb/installscript.qs?dl=0). My app's extension is *.sp*. How to change it to yours please and should a put some *.ico* file into the folder that script file is? – Franky Sep 15 '17 at 18:00
  • @Andre Silva In my case problem had been appearing until I removed the preceding space from the string. I used \"%1\" instead of \" %1\". Then complete line should be "@TargetDir@\\BobiSoft.exe \"%1\"" – Hareen Laks Nov 13 '20 at 10:51