How to set a flag as default on an *.EXE file?

When I open Sumatra I need inverted colors by default. But even though I changed the shortcuts to: "/sumatraPDF.exe" -invert-colors the program runs without the flag when I double click a PDF file at a time where the program is closed.

How do I make sure the flag is used when double clicking PDF files?


Solution 1:

How do I make sure the flag is used when double clicking pdf files?

You need to modify the command that is run, using ftype:

  1. Find out the file type using assoc:

    assoc .pdf
    
  2. This will return something similar to:

    .pdf=AcroExch.Document.DC
    
  3. Now use ftype to get the current command run for a .pdf:

    ftype AcroExch.Document.DC
    
  4. This will return something similar to:

    AcroExch.Document.DC="C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" "%1"
    
  5. Now set up a new command with your extra flag:

    ftype AcroExch.Document.DC="C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" -invert-colors "%1"
    

Note:

  • I've used Acrobat in my example above as I don't have Sumatra installed.

Further Reading

  • An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
  • assoc - Display or change the association between a file extension and a fileType
  • ftype - Display or change the link between a FileType and an executable program.